{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<table style=\"float:left; border:none\">\n",
    "   <tr style=\"border:none; background-color: #ffffff\">\n",
    "       <td style=\"border:none\">\n",
    "           <a href=\"http://bokeh.pydata.org/\">     \n",
    "           <img \n",
    "               src=\"assets/bokeh-transparent.png\" \n",
    "               style=\"width:50px\"\n",
    "           >\n",
    "           </a>    \n",
    "       </td>\n",
    "       <td style=\"border:none\">\n",
    "           <h1>Bokeh 教程</h1>\n",
    "       </td>\n",
    "   </tr>\n",
    "</table>\n",
    "\n",
    "<div style=\"float:right;\"><h2>06. 关联和交互</h2></div>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "    <div class=\"bk-root\">\n",
       "        <a href=\"https://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
       "        <span id=\"0e1a4336-7bac-4651-a634-e9196203d529\">Loading BokehJS ...</span>\n",
       "    </div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "\n",
       "(function(root) {\n",
       "  function now() {\n",
       "    return new Date();\n",
       "  }\n",
       "\n",
       "  var force = true;\n",
       "\n",
       "  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n",
       "    root._bokeh_onload_callbacks = [];\n",
       "    root._bokeh_is_loading = undefined;\n",
       "  }\n",
       "\n",
       "  var JS_MIME_TYPE = 'application/javascript';\n",
       "  var HTML_MIME_TYPE = 'text/html';\n",
       "  var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n",
       "  var CLASS_NAME = 'output_bokeh rendered_html';\n",
       "\n",
       "  /**\n",
       "   * Render data to the DOM node\n",
       "   */\n",
       "  function render(props, node) {\n",
       "    var script = document.createElement(\"script\");\n",
       "    node.appendChild(script);\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when an output is cleared or removed\n",
       "   */\n",
       "  function handleClearOutput(event, handle) {\n",
       "    var cell = handle.cell;\n",
       "\n",
       "    var id = cell.output_area._bokeh_element_id;\n",
       "    var server_id = cell.output_area._bokeh_server_id;\n",
       "    // Clean up Bokeh references\n",
       "    if (id !== undefined) {\n",
       "      Bokeh.index[id].model.document.clear();\n",
       "      delete Bokeh.index[id];\n",
       "    }\n",
       "\n",
       "    if (server_id !== undefined) {\n",
       "      // Clean up Bokeh references\n",
       "      var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n",
       "      cell.notebook.kernel.execute(cmd, {\n",
       "        iopub: {\n",
       "          output: function(msg) {\n",
       "            var element_id = msg.content.text.trim();\n",
       "            Bokeh.index[element_id].model.document.clear();\n",
       "            delete Bokeh.index[element_id];\n",
       "          }\n",
       "        }\n",
       "      });\n",
       "      // Destroy server and session\n",
       "      var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n",
       "      cell.notebook.kernel.execute(cmd);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  /**\n",
       "   * Handle when a new output is added\n",
       "   */\n",
       "  function handleAddOutput(event, handle) {\n",
       "    var output_area = handle.output_area;\n",
       "    var output = handle.output;\n",
       "\n",
       "    // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n",
       "    if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n",
       "      return\n",
       "    }\n",
       "\n",
       "    var toinsert = output_area.element.find(`.${CLASS_NAME.split(' ')[0]}`);\n",
       "\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n",
       "      toinsert[0].firstChild.textContent = output.data[JS_MIME_TYPE];\n",
       "      // store reference to embed id on output_area\n",
       "      output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n",
       "    }\n",
       "    if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n",
       "      var bk_div = document.createElement(\"div\");\n",
       "      bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n",
       "      var script_attrs = bk_div.children[0].attributes;\n",
       "      for (var i = 0; i < script_attrs.length; i++) {\n",
       "        toinsert[0].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n",
       "      }\n",
       "      // store reference to server id on output_area\n",
       "      output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n",
       "    }\n",
       "  }\n",
       "\n",
       "  function register_renderer(events, OutputArea) {\n",
       "\n",
       "    function append_mime(data, metadata, element) {\n",
       "      // create a DOM node to render to\n",
       "      var toinsert = this.create_output_subarea(\n",
       "        metadata,\n",
       "        CLASS_NAME,\n",
       "        EXEC_MIME_TYPE\n",
       "      );\n",
       "      this.keyboard_manager.register_events(toinsert);\n",
       "      // Render to node\n",
       "      var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n",
       "      render(props, toinsert[0]);\n",
       "      element.append(toinsert);\n",
       "      return toinsert\n",
       "    }\n",
       "\n",
       "    /* Handle when an output is cleared or removed */\n",
       "    events.on('clear_output.CodeCell', handleClearOutput);\n",
       "    events.on('delete.Cell', handleClearOutput);\n",
       "\n",
       "    /* Handle when a new output is added */\n",
       "    events.on('output_added.OutputArea', handleAddOutput);\n",
       "\n",
       "    /**\n",
       "     * Register the mime type and append_mime function with output_area\n",
       "     */\n",
       "    OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n",
       "      /* Is output safe? */\n",
       "      safe: true,\n",
       "      /* Index of renderer in `output_area.display_order` */\n",
       "      index: 0\n",
       "    });\n",
       "  }\n",
       "\n",
       "  // register the mime type if in Jupyter Notebook environment and previously unregistered\n",
       "  if (root.Jupyter !== undefined) {\n",
       "    var events = require('base/js/events');\n",
       "    var OutputArea = require('notebook/js/outputarea').OutputArea;\n",
       "\n",
       "    if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n",
       "      register_renderer(events, OutputArea);\n",
       "    }\n",
       "  }\n",
       "\n",
       "  \n",
       "  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n",
       "    root._bokeh_timeout = Date.now() + 5000;\n",
       "    root._bokeh_failed_load = false;\n",
       "  }\n",
       "\n",
       "  var NB_LOAD_WARNING = {'data': {'text/html':\n",
       "     \"<div style='background-color: #fdd'>\\n\"+\n",
       "     \"<p>\\n\"+\n",
       "     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
       "     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
       "     \"</p>\\n\"+\n",
       "     \"<ul>\\n\"+\n",
       "     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
       "     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
       "     \"</ul>\\n\"+\n",
       "     \"<code>\\n\"+\n",
       "     \"from bokeh.resources import INLINE\\n\"+\n",
       "     \"output_notebook(resources=INLINE)\\n\"+\n",
       "     \"</code>\\n\"+\n",
       "     \"</div>\"}};\n",
       "\n",
       "  function display_loaded() {\n",
       "    var el = document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\");\n",
       "    if (el != null) {\n",
       "      el.textContent = \"BokehJS is loading...\";\n",
       "    }\n",
       "    if (root.Bokeh !== undefined) {\n",
       "      if (el != null) {\n",
       "        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n",
       "      }\n",
       "    } else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(display_loaded, 100)\n",
       "    }\n",
       "  }\n",
       "\n",
       "\n",
       "  function run_callbacks() {\n",
       "    try {\n",
       "      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
       "    }\n",
       "    finally {\n",
       "      delete root._bokeh_onload_callbacks\n",
       "    }\n",
       "    console.info(\"Bokeh: all callbacks have finished\");\n",
       "  }\n",
       "\n",
       "  function load_libs(js_urls, callback) {\n",
       "    root._bokeh_onload_callbacks.push(callback);\n",
       "    if (root._bokeh_is_loading > 0) {\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
       "      return null;\n",
       "    }\n",
       "    if (js_urls == null || js_urls.length === 0) {\n",
       "      run_callbacks();\n",
       "      return null;\n",
       "    }\n",
       "    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
       "    root._bokeh_is_loading = js_urls.length;\n",
       "    for (var i = 0; i < js_urls.length; i++) {\n",
       "      var url = js_urls[i];\n",
       "      var s = document.createElement('script');\n",
       "      s.src = url;\n",
       "      s.async = false;\n",
       "      s.onreadystatechange = s.onload = function() {\n",
       "        root._bokeh_is_loading--;\n",
       "        if (root._bokeh_is_loading === 0) {\n",
       "          console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
       "          run_callbacks()\n",
       "        }\n",
       "      };\n",
       "      s.onerror = function() {\n",
       "        console.warn(\"failed to load library \" + url);\n",
       "      };\n",
       "      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
       "      document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "  };var element = document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\");\n",
       "  if (element == null) {\n",
       "    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '0e1a4336-7bac-4651-a634-e9196203d529' but no matching script tag was found. \")\n",
       "    return false;\n",
       "  }\n",
       "\n",
       "  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.10.min.js\"];\n",
       "\n",
       "  var inline_js = [\n",
       "    function(Bokeh) {\n",
       "      Bokeh.set_log_level(\"info\");\n",
       "    },\n",
       "    \n",
       "    function(Bokeh) {\n",
       "      \n",
       "    },\n",
       "    function(Bokeh) {\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n",
       "      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n",
       "    }\n",
       "  ];\n",
       "\n",
       "  function run_inline_js() {\n",
       "    \n",
       "    if ((root.Bokeh !== undefined) || (force === true)) {\n",
       "      for (var i = 0; i < inline_js.length; i++) {\n",
       "        inline_js[i].call(root, root.Bokeh);\n",
       "      }if (force === true) {\n",
       "        display_loaded();\n",
       "      }} else if (Date.now() < root._bokeh_timeout) {\n",
       "      setTimeout(run_inline_js, 100);\n",
       "    } else if (!root._bokeh_failed_load) {\n",
       "      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
       "      root._bokeh_failed_load = true;\n",
       "    } else if (force !== true) {\n",
       "      var cell = $(document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\")).parents('.cell').data().cell;\n",
       "      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
       "    }\n",
       "\n",
       "  }\n",
       "\n",
       "  if (root._bokeh_is_loading === 0) {\n",
       "    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "    run_inline_js();\n",
       "  } else {\n",
       "    load_libs(js_urls, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
       "      run_inline_js();\n",
       "    });\n",
       "  }\n",
       "}(window));"
      ],
      "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n  function now() {\n    return new Date();\n  }\n\n  var force = true;\n\n  if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n    root._bokeh_onload_callbacks = [];\n    root._bokeh_is_loading = undefined;\n  }\n\n  \n\n  \n  if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n    root._bokeh_timeout = Date.now() + 5000;\n    root._bokeh_failed_load = false;\n  }\n\n  var NB_LOAD_WARNING = {'data': {'text/html':\n     \"<div style='background-color: #fdd'>\\n\"+\n     \"<p>\\n\"+\n     \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n     \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n     \"</p>\\n\"+\n     \"<ul>\\n\"+\n     \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n     \"<li>use INLINE resources instead, as so:</li>\\n\"+\n     \"</ul>\\n\"+\n     \"<code>\\n\"+\n     \"from bokeh.resources import INLINE\\n\"+\n     \"output_notebook(resources=INLINE)\\n\"+\n     \"</code>\\n\"+\n     \"</div>\"}};\n\n  function display_loaded() {\n    var el = document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\");\n    if (el != null) {\n      el.textContent = \"BokehJS is loading...\";\n    }\n    if (root.Bokeh !== undefined) {\n      if (el != null) {\n        el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n      }\n    } else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(display_loaded, 100)\n    }\n  }\n\n\n  function run_callbacks() {\n    try {\n      root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n    }\n    finally {\n      delete root._bokeh_onload_callbacks\n    }\n    console.info(\"Bokeh: all callbacks have finished\");\n  }\n\n  function load_libs(js_urls, callback) {\n    root._bokeh_onload_callbacks.push(callback);\n    if (root._bokeh_is_loading > 0) {\n      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n      return null;\n    }\n    if (js_urls == null || js_urls.length === 0) {\n      run_callbacks();\n      return null;\n    }\n    console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n    root._bokeh_is_loading = js_urls.length;\n    for (var i = 0; i < js_urls.length; i++) {\n      var url = js_urls[i];\n      var s = document.createElement('script');\n      s.src = url;\n      s.async = false;\n      s.onreadystatechange = s.onload = function() {\n        root._bokeh_is_loading--;\n        if (root._bokeh_is_loading === 0) {\n          console.log(\"Bokeh: all BokehJS libraries loaded\");\n          run_callbacks()\n        }\n      };\n      s.onerror = function() {\n        console.warn(\"failed to load library \" + url);\n      };\n      console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n      document.getElementsByTagName(\"head\")[0].appendChild(s);\n    }\n  };var element = document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\");\n  if (element == null) {\n    console.log(\"Bokeh: ERROR: autoload.js configured with elementid '0e1a4336-7bac-4651-a634-e9196203d529' but no matching script tag was found. \")\n    return false;\n  }\n\n  var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.10.min.js\"];\n\n  var inline_js = [\n    function(Bokeh) {\n      Bokeh.set_log_level(\"info\");\n    },\n    \n    function(Bokeh) {\n      \n    },\n    function(Bokeh) {\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.10.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.10.min.css\");\n      console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.10.min.css\");\n    }\n  ];\n\n  function run_inline_js() {\n    \n    if ((root.Bokeh !== undefined) || (force === true)) {\n      for (var i = 0; i < inline_js.length; i++) {\n        inline_js[i].call(root, root.Bokeh);\n      }if (force === true) {\n        display_loaded();\n      }} else if (Date.now() < root._bokeh_timeout) {\n      setTimeout(run_inline_js, 100);\n    } else if (!root._bokeh_failed_load) {\n      console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n      root._bokeh_failed_load = true;\n    } else if (force !== true) {\n      var cell = $(document.getElementById(\"0e1a4336-7bac-4651-a634-e9196203d529\")).parents('.cell').data().cell;\n      cell.output_area.append_execute_result(NB_LOAD_WARNING)\n    }\n\n  }\n\n  if (root._bokeh_is_loading === 0) {\n    console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n    run_inline_js();\n  } else {\n    load_libs(js_urls, function() {\n      console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n      run_inline_js();\n    });\n  }\n}(window));"
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.io import output_notebook, show\n",
    "from bokeh.plotting import figure\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在上一章，我们知道了怎么把多个图表（plot）放在一个布局（layout）里。现在，我们就来看看怎么把不同的图表联系起来，怎么把图表和控件（widget）联系起来。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Linked Interactions\n",
    "\n",
    "不同的Bokeh图表之间是可以有联系的。例如，两个（或更多）图的范围可能是由联系的，当一个图被平移（或放大，或其范围变化），其它的图也相应更新保持一致。还可以将两个图的选择（selection）联系起来，当在一个图上选择某项时，另一个图中对应的项也被选中。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Linked panning（相连的平移）\n",
    "\n",
    "相连的平移（多个图的range保持同步）在Bokeh里非常容易。您只需让两个（或多个）图共享适当的range对象就可以了。下面的例子展示了如何通过三种不同的方式连接这些图的range："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"6d9e6362-b3ae-47be-a13f-7e4c52dd60ea\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"7af73ce2-e987-471b-9339-71b38530dea9\":{\"roots\":{\"references\":[{\"attributes\":{\"children\":[{\"id\":\"11f639e8-32f3-4de3-bcdf-0449668585c7\",\"type\":\"Row\"}]},\"id\":\"24bb92d5-9b35-4902-8a36-d67153fec49d\",\"type\":\"Column\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10],\"y\":[5,4,3,2,1,0,1,2,3,4,5]}},\"id\":\"2a5ec556-33d1-441c-acf0-bf89ca277a50\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"671201dd-29a6-4086-b8c7-6b8167b622e7\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"671201dd-29a6-4086-b8c7-6b8167b622e7\",\"type\":\"BasicTicker\"}},\"id\":\"bac2ac4b-3206-48f9-9401-81cedd9c1211\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"31cec1b2-2e21-443c-a929-6462018e22fd\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1a625d5e-3aee-4d9e-95a1-d2f555c19230\",\"type\":\"BasicTicker\"}},\"id\":\"4571eb51-a5fd-414f-a902-7fb3d3768968\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1a625d5e-3aee-4d9e-95a1-d2f555c19230\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1a625d5e-3aee-4d9e-95a1-d2f555c19230\",\"type\":\"BasicTicker\"}},\"id\":\"093235ef-e6e2-4f04-be6b-5c6198880070\",\"type\":\"Grid\"},{\"attributes\":{\"source\":{\"id\":\"0ff45243-8a23-4878-a1b8-94951aa055c7\",\"type\":\"ColumnDataSource\"}},\"id\":\"3a289091-1509-4332-a983-0952ffb91ca3\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"d1a55790-7a1f-4007-aa1a-09922158a224\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"8a042d46-83dd-4a54-af78-7e1da89200bc\",\"type\":\"PanTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"d1dc9a76-3560-449f-8052-c36387b50c0a\",\"type\":\"Title\"},{\"attributes\":{\"source\":{\"id\":\"2a5ec556-33d1-441c-acf0-bf89ca277a50\",\"type\":\"ColumnDataSource\"}},\"id\":\"9594aeaa-c128-4bb6-8c35-fc9a8492ed60\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"ec3c2a02-7ac9-416c-a557-675d0ff792f3\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"children\":[{\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"11f639e8-32f3-4de3-bcdf-0449668585c7\",\"type\":\"Row\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"4ea69d02-6114-420c-9259-d3bbea747941\",\"type\":\"Square\"},{\"attributes\":{\"data_source\":{\"id\":\"2a5ec556-33d1-441c-acf0-bf89ca277a50\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"b2e5162c-1ef6-41ad-8d8d-8bf0a8a2fa6f\",\"type\":\"Square\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"4ea69d02-6114-420c-9259-d3bbea747941\",\"type\":\"Square\"},\"selection_glyph\":null,\"view\":{\"id\":\"9594aeaa-c128-4bb6-8c35-fc9a8492ed60\",\"type\":\"CDSView\"}},\"id\":\"601af479-932a-4fad-8879-b6e0886af8f2\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"data_source\":{\"id\":\"0ff45243-8a23-4878-a1b8-94951aa055c7\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"064dbe95-c40c-4896-ae2e-b68d2810e92e\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"6c5af81f-92dd-44bc-a092-27df514cd63d\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"3a289091-1509-4332-a983-0952ffb91ca3\",\"type\":\"CDSView\"}},\"id\":\"ad30601a-751a-4223-be86-f6edad1d2b45\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"7eca5afc-edba-4426-b36c-8c9b859b6aa2\",\"type\":\"PanTool\"},{\"id\":\"ec3c2a02-7ac9-416c-a557-675d0ff792f3\",\"type\":\"WheelZoomTool\"}]},\"id\":\"0480a457-0b70-4937-97db-6c3a477c0788\",\"type\":\"Toolbar\"},{\"attributes\":{\"fill_color\":{\"value\":\"navy\"},\"line_color\":{\"value\":\"navy\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"064dbe95-c40c-4896-ae2e-b68d2810e92e\",\"type\":\"Circle\"},{\"attributes\":{\"callback\":null},\"id\":\"ca759ac6-baac-4b26-8868-c99d1aa56c0f\",\"type\":\"DataRange1d\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"d7a0bbd5-ca0b-41d4-a99b-595fd24833e6\",\"type\":\"PanTool\"},{\"id\":\"90f64878-ee1c-4a57-821f-dc6aa18da859\",\"type\":\"WheelZoomTool\"}]},\"id\":\"de04a25b-2b54-4702-9458-be48f3caa7bf\",\"type\":\"Toolbar\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"6c5af81f-92dd-44bc-a092-27df514cd63d\",\"type\":\"Circle\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10],\"y\":[10,9,8,7,6,5,4,3,2,1,0]}},\"id\":\"297bab3b-48bf-4288-a9ef-5cb815df7a51\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"31cec1b2-2e21-443c-a929-6462018e22fd\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0105c530-ef92-489b-bdec-d8f247f58596\",\"type\":\"BasicTicker\"}},\"id\":\"c06c29f7-34ec-48f3-8be0-6145db40b1d2\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"241a92ed-3ec6-4995-a4a6-b5bba710d2d9\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"29981d68-654c-4943-941f-ac3c111a39a5\",\"type\":\"BasicTicker\"}},\"id\":\"87119256-c6c6-4aac-a7c4-9b2356cf8703\",\"type\":\"LinearAxis\"},{\"attributes\":{\"fill_color\":{\"value\":\"firebrick\"},\"line_color\":{\"value\":\"firebrick\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"90fbd159-3ed2-4a51-a03a-1753eb6c54dc\",\"type\":\"Triangle\"},{\"attributes\":{},\"id\":\"b5469ae7-0e2e-4aab-8c09-a50b53bd0eaa\",\"type\":\"LinearScale\"},{\"attributes\":{\"formatter\":{\"id\":\"21885102-f3ce-4043-955a-8015ce56f7d6\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0105c530-ef92-489b-bdec-d8f247f58596\",\"type\":\"BasicTicker\"}},\"id\":\"7d126279-9409-4610-9f08-c43548c11e2f\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"58588267-91f2-4e7a-a5a6-e0315f411755\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"5e95d991-1ca9-4556-9993-c040a155e2b6\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"da8cfbd6-24e2-4b32-baf8-2ca80a68675c\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"0105c530-ef92-489b-bdec-d8f247f58596\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"58588267-91f2-4e7a-a5a6-e0315f411755\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9f46d589-0d7c-4cc4-ae07-2f0b4320d2f2\",\"type\":\"BasicTicker\"}},\"id\":\"5b0a1acd-b725-4dc2-a236-f5e91eabe9eb\",\"type\":\"LinearAxis\"},{\"attributes\":{\"plot\":{\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"29981d68-654c-4943-941f-ac3c111a39a5\",\"type\":\"BasicTicker\"}},\"id\":\"642d7cb4-b6d1-488d-8673-d87cad668c38\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"9f46d589-0d7c-4cc4-ae07-2f0b4320d2f2\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"9f46d589-0d7c-4cc4-ae07-2f0b4320d2f2\",\"type\":\"BasicTicker\"}},\"id\":\"49ece30b-e632-4198-a740-b34fb1e40d8e\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"470d0dd5-b8c1-4d73-866a-63da73e75663\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"241a92ed-3ec6-4995-a4a6-b5bba710d2d9\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"d7a0bbd5-ca0b-41d4-a99b-595fd24833e6\",\"type\":\"PanTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"olive\"},\"line_color\":{\"value\":\"olive\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"b2e5162c-1ef6-41ad-8d8d-8bf0a8a2fa6f\",\"type\":\"Square\"},{\"attributes\":{},\"id\":\"e343f35e-7e71-48bc-bd5d-b5117ae9fd25\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"90f64878-ee1c-4a57-821f-dc6aa18da859\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":10},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"acabd172-5ee3-4dc3-8794-8bc5194ea472\",\"type\":\"Triangle\"},{\"attributes\":{\"data_source\":{\"id\":\"297bab3b-48bf-4288-a9ef-5cb815df7a51\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"90fbd159-3ed2-4a51-a03a-1753eb6c54dc\",\"type\":\"Triangle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"acabd172-5ee3-4dc3-8794-8bc5194ea472\",\"type\":\"Triangle\"},\"selection_glyph\":null,\"view\":{\"id\":\"71ef6171-fb92-4eb2-a6de-8eb653b00a61\",\"type\":\"CDSView\"}},\"id\":\"50ed4b39-d4d9-4a42-beb6-021f2dd324bf\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"31e703e0-41e5-464c-be60-0f5136c62319\",\"type\":\"LinearScale\"},{\"attributes\":{\"source\":{\"id\":\"297bab3b-48bf-4288-a9ef-5cb815df7a51\",\"type\":\"ColumnDataSource\"}},\"id\":\"71ef6171-fb92-4eb2-a6de-8eb653b00a61\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"7eca5afc-edba-4426-b36c-8c9b859b6aa2\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"21885102-f3ce-4043-955a-8015ce56f7d6\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"e9926c86-2853-4815-ac69-5ba0dfc64eb0\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"34683820-a42c-4f72-bf51-060f68fa0cbc\",\"type\":\"Title\"},{\"attributes\":{\"sizing_mode\":\"scale_width\",\"toolbar_location\":\"above\",\"tools\":[{\"id\":\"8a042d46-83dd-4a54-af78-7e1da89200bc\",\"type\":\"PanTool\"},{\"id\":\"d1a55790-7a1f-4007-aa1a-09922158a224\",\"type\":\"WheelZoomTool\"},{\"id\":\"d7a0bbd5-ca0b-41d4-a99b-595fd24833e6\",\"type\":\"PanTool\"},{\"id\":\"90f64878-ee1c-4a57-821f-dc6aa18da859\",\"type\":\"WheelZoomTool\"},{\"id\":\"7eca5afc-edba-4426-b36c-8c9b859b6aa2\",\"type\":\"PanTool\"},{\"id\":\"ec3c2a02-7ac9-416c-a557-675d0ff792f3\",\"type\":\"WheelZoomTool\"}]},\"id\":\"a89afb34-1bd2-4016-8f68-9de2e5ca3627\",\"type\":\"ToolbarBox\"},{\"attributes\":{},\"id\":\"29981d68-654c-4943-941f-ac3c111a39a5\",\"type\":\"BasicTicker\"},{\"attributes\":{\"below\":[{\"id\":\"87119256-c6c6-4aac-a7c4-9b2356cf8703\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"a565de56-28b7-4155-8b80-e27d63d2ccb5\",\"type\":\"LinearAxis\"}],\"plot_height\":250,\"plot_width\":250,\"renderers\":[{\"id\":\"87119256-c6c6-4aac-a7c4-9b2356cf8703\",\"type\":\"LinearAxis\"},{\"id\":\"642d7cb4-b6d1-488d-8673-d87cad668c38\",\"type\":\"Grid\"},{\"id\":\"a565de56-28b7-4155-8b80-e27d63d2ccb5\",\"type\":\"LinearAxis\"},{\"id\":\"0b13066b-b1c4-427b-814f-5672a331e159\",\"type\":\"Grid\"},{\"id\":\"601af479-932a-4fad-8879-b6e0886af8f2\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"34683820-a42c-4f72-bf51-060f68fa0cbc\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"0480a457-0b70-4937-97db-6c3a477c0788\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"a8b92ea0-4bec-4e96-8954-5d82383bebc7\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"31e703e0-41e5-464c-be60-0f5136c62319\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"ca759ac6-baac-4b26-8868-c99d1aa56c0f\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"da8cfbd6-24e2-4b32-baf8-2ca80a68675c\",\"type\":\"LinearScale\"}},\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"children\":[{\"id\":\"a89afb34-1bd2-4016-8f68-9de2e5ca3627\",\"type\":\"ToolbarBox\"},{\"id\":\"24bb92d5-9b35-4902-8a36-d67153fec49d\",\"type\":\"Column\"}]},\"id\":\"47b831a5-eba8-4751-8ab0-ceb0b27d9c24\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"cd2e29a0-a061-4d69-b7bd-f7f7c5fcf320\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"cd2e29a0-a061-4d69-b7bd-f7f7c5fcf320\",\"type\":\"BasicTicker\"}},\"id\":\"0b13066b-b1c4-427b-814f-5672a331e159\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"e9926c86-2853-4815-ac69-5ba0dfc64eb0\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"d681999b-37cc-45cc-bb5a-1833a7646bb9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"cd2e29a0-a061-4d69-b7bd-f7f7c5fcf320\",\"type\":\"BasicTicker\"}},\"id\":\"a565de56-28b7-4155-8b80-e27d63d2ccb5\",\"type\":\"LinearAxis\"},{\"attributes\":{\"below\":[{\"id\":\"732711e0-cc22-47f5-9644-82212d548ac2\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"4571eb51-a5fd-414f-a902-7fb3d3768968\",\"type\":\"LinearAxis\"}],\"plot_height\":250,\"plot_width\":250,\"renderers\":[{\"id\":\"732711e0-cc22-47f5-9644-82212d548ac2\",\"type\":\"LinearAxis\"},{\"id\":\"bac2ac4b-3206-48f9-9401-81cedd9c1211\",\"type\":\"Grid\"},{\"id\":\"4571eb51-a5fd-414f-a902-7fb3d3768968\",\"type\":\"LinearAxis\"},{\"id\":\"093235ef-e6e2-4f04-be6b-5c6198880070\",\"type\":\"Grid\"},{\"id\":\"ad30601a-751a-4223-be86-f6edad1d2b45\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"470d0dd5-b8c1-4d73-866a-63da73e75663\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"0731ef2f-84f5-4af4-8c4d-c512ba9cbd07\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"a8b92ea0-4bec-4e96-8954-5d82383bebc7\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"b1c74d87-f9da-4f44-94b0-daef4e5ab01e\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"d6d57db2-67b2-426b-8c48-4d66292cb267\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"2b9d559b-cf54-4e45-aa39-dad657b209cf\",\"type\":\"LinearScale\"}},\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"formatter\":{\"id\":\"e343f35e-7e71-48bc-bd5d-b5117ae9fd25\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"ae955e81-fe05-4fd1-a0b9-7754fc1eb61b\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"671201dd-29a6-4086-b8c7-6b8167b622e7\",\"type\":\"BasicTicker\"}},\"id\":\"732711e0-cc22-47f5-9644-82212d548ac2\",\"type\":\"LinearAxis\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"8a042d46-83dd-4a54-af78-7e1da89200bc\",\"type\":\"PanTool\"},{\"id\":\"d1a55790-7a1f-4007-aa1a-09922158a224\",\"type\":\"WheelZoomTool\"}]},\"id\":\"0731ef2f-84f5-4af4-8c4d-c512ba9cbd07\",\"type\":\"Toolbar\"},{\"attributes\":{\"below\":[{\"id\":\"7d126279-9409-4610-9f08-c43548c11e2f\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"5b0a1acd-b725-4dc2-a236-f5e91eabe9eb\",\"type\":\"LinearAxis\"}],\"plot_height\":250,\"plot_width\":250,\"renderers\":[{\"id\":\"7d126279-9409-4610-9f08-c43548c11e2f\",\"type\":\"LinearAxis\"},{\"id\":\"c06c29f7-34ec-48f3-8be0-6145db40b1d2\",\"type\":\"Grid\"},{\"id\":\"5b0a1acd-b725-4dc2-a236-f5e91eabe9eb\",\"type\":\"LinearAxis\"},{\"id\":\"49ece30b-e632-4198-a740-b34fb1e40d8e\",\"type\":\"Grid\"},{\"id\":\"50ed4b39-d4d9-4a42-beb6-021f2dd324bf\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"d1dc9a76-3560-449f-8052-c36387b50c0a\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"de04a25b-2b54-4702-9458-be48f3caa7bf\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"a8b92ea0-4bec-4e96-8954-5d82383bebc7\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"b5469ae7-0e2e-4aab-8c09-a50b53bd0eaa\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"d6d57db2-67b2-426b-8c48-4d66292cb267\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"5e95d991-1ca9-4556-9993-c040a155e2b6\",\"type\":\"LinearScale\"}},\"id\":\"2fcbaedd-7d99-4bf0-bc58-2f1691764888\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"a8b92ea0-4bec-4e96-8954-5d82383bebc7\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null},\"id\":\"d6d57db2-67b2-426b-8c48-4d66292cb267\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0,1,2,3,4,5,6,7,8,9,10],\"y\":[0,1,2,3,4,5,6,7,8,9,10]}},\"id\":\"0ff45243-8a23-4878-a1b8-94951aa055c7\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"b1c74d87-f9da-4f44-94b0-daef4e5ab01e\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"2b9d559b-cf54-4e45-aa39-dad657b209cf\",\"type\":\"LinearScale\"}],\"root_ids\":[\"47b831a5-eba8-4751-8ab0-ceb0b27d9c24\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"7af73ce2-e987-471b-9339-71b38530dea9\",\"elementid\":\"6d9e6362-b3ae-47be-a13f-7e4c52dd60ea\",\"modelid\":\"47b831a5-eba8-4751-8ab0-ceb0b27d9c24\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "47b831a5-eba8-4751-8ab0-ceb0b27d9c24"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.layouts import gridplot\n",
    "\n",
    "x = list(range(11))\n",
    "y0, y1, y2 = x, [10-i for i in x], [abs(i-5) for i in x]\n",
    "\n",
    "plot_options = dict(width=250, plot_height=250, tools='pan,wheel_zoom')\n",
    "\n",
    "# create a new plot\n",
    "s1 = figure(**plot_options)\n",
    "s1.circle(x, y0, size=10, color=\"navy\")\n",
    "\n",
    "# create a new plot and share both ranges\n",
    "s2 = figure(x_range=s1.x_range, y_range=s1.y_range, **plot_options)\n",
    "s2.triangle(x, y1, size=10, color=\"firebrick\")\n",
    "\n",
    "# create a new plot and share only one range\n",
    "s3 = figure(x_range=s1.x_range, **plot_options)\n",
    "s3.square(x, y2, size=10, color=\"olive\")\n",
    "\n",
    "p = gridplot([[s1, s2, s3]])\n",
    "\n",
    "# show the results\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: create two plots in a gridplot, and link their ranges\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Linked brushing\n",
    "\n",
    "相连的选择（selection）通过类似的方式完成，在图块之间共享数据源。注意，通常 ``bokeh.plotting`` 和 ``bokeh.charts`` 会自动创建一个缺省数据源。然而，为了共享数据源，我们必须手动创建它们并显式地传递。下面的例子说明了这一点："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"12cc17fa-a5d6-4d53-8ce3-e4c6707648cf\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"b614d9ac-c753-4b49-a00f-5b8e8c45b07d\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"20ee64e6-944b-458f-98d0-951a801053f8\",\"type\":\"HelpTool\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"4efdee2e-1861-4b83-b7f4-d3aba9dbc1b9\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"callback\":null,\"overlay\":{\"id\":\"f15098de-c897-43c9-87bc-de6819613d43\",\"type\":\"PolyAnnotation\"}},\"id\":\"ac3e2819-6a07-46d2-8533-d795de4cadcc\",\"type\":\"LassoSelectTool\"},{\"attributes\":{\"source\":{\"id\":\"c0ee0867-d3b9-43c6-a7e1-cfcdadba848a\",\"type\":\"ColumnDataSource\"}},\"id\":\"01f5b0ce-19aa-4e02-9e14-dff45855a40f\",\"type\":\"CDSView\"},{\"attributes\":{\"callback\":null},\"id\":\"58bbcbc3-cb84-43d3-b61f-2c51aeaa84b4\",\"type\":\"DataRange1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fb16b898-bfa6-41e5-8fe5-ddc192e93ed9\",\"type\":\"BasicTicker\"}},\"id\":\"8153ac5d-9556-4e82-b330-214943b3ec59\",\"type\":\"Grid\"},{\"attributes\":{\"callback\":null},\"id\":\"7f11d9e0-7a69-4fe6-ac0a-adbbf3e20f62\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"96a6ad86-50a5-4a4a-8578-b3e32aa3afd5\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"b0847014-4209-4537-92b7-a3ce3c5c8605\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"ec4e822d-e5c0-48f8-b8b9-3263a9f0466e\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"0396ac7b-b514-4e6e-bfd1-afd015e7def0\",\"type\":\"LinearScale\"},{\"attributes\":{\"plot\":{\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"cbe24727-2e06-428a-ad4f-3bb09b3b2141\",\"type\":\"BasicTicker\"}},\"id\":\"dba3bc7e-b44c-4e9c-b187-f22cf4cbe5c5\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"f277dba7-73f5-4c5e-aba0-872a49e83ee7\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"cbe24727-2e06-428a-ad4f-3bb09b3b2141\",\"type\":\"BasicTicker\"}},\"id\":\"0fe5b33c-82f3-412e-8ce8-5d213ce809f6\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"cbe24727-2e06-428a-ad4f-3bb09b3b2141\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"03a59ad1-7523-4702-903d-6ebcf6d7e8ee\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1aea9a31-d440-446e-a8b0-69e2e8293893\",\"type\":\"BasicTicker\"}},\"id\":\"ec0008c2-7fc8-4e4e-8a95-b52b8586392c\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1aea9a31-d440-446e-a8b0-69e2e8293893\",\"type\":\"BasicTicker\"},{\"attributes\":{\"plot\":{\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fd882a64-4bc4-43e8-a18c-2696ca49811e\",\"type\":\"BasicTicker\"}},\"id\":\"8a9beb71-3944-466e-95c6-62e7fda5b83d\",\"type\":\"Grid\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y1\"}},\"id\":\"ee28c1be-c113-4103-a62d-fccacf9174eb\",\"type\":\"Circle\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"1aea9a31-d440-446e-a8b0-69e2e8293893\",\"type\":\"BasicTicker\"}},\"id\":\"9c112892-b54a-41ff-8d8c-d99c6f4e7ba2\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"03a59ad1-7523-4702-903d-6ebcf6d7e8ee\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"formatter\":{\"id\":\"1c811fb0-a3c1-4543-a2d3-fb953ba2c68f\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fb16b898-bfa6-41e5-8fe5-ddc192e93ed9\",\"type\":\"BasicTicker\"}},\"id\":\"11c00602-883c-4275-be97-9565e09a683f\",\"type\":\"LinearAxis\"},{\"attributes\":{\"callback\":null,\"overlay\":{\"id\":\"4efdee2e-1861-4b83-b7f4-d3aba9dbc1b9\",\"type\":\"BoxAnnotation\"},\"renderers\":[{\"id\":\"0d731b71-369e-41f7-bde6-0b42cec0165f\",\"type\":\"GlyphRenderer\"}]},\"id\":\"731d524a-0200-4d6d-991f-30d18d13a31d\",\"type\":\"BoxSelectTool\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y1\"}},\"id\":\"435efbfa-db40-49ec-a22c-012487e53a07\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"fb16b898-bfa6-41e5-8fe5-ddc192e93ed9\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null,\"overlay\":{\"id\":\"4e15a3d1-ebbd-464b-a3d5-e6b70d65185b\",\"type\":\"PolyAnnotation\"}},\"id\":\"3f05fdf5-2c17-4a1d-995c-c9a63c762801\",\"type\":\"LassoSelectTool\"},{\"attributes\":{\"data_source\":{\"id\":\"c0ee0867-d3b9-43c6-a7e1-cfcdadba848a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"3ae79a1a-a582-4a87-b2d3-4b138d2bb5f6\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"049da368-84dd-4fe9-93bc-adec3836322e\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"01f5b0ce-19aa-4e02-9e14-dff45855a40f\",\"type\":\"CDSView\"}},\"id\":\"53d22ebc-49d7-4683-ae1f-b2e44818bfbc\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"607c2d48-b279-41ee-93b1-a74d3e0f8d91\",\"type\":\"HelpTool\"},{\"attributes\":{\"sizing_mode\":\"scale_width\",\"toolbar_location\":\"above\",\"tools\":[{\"id\":\"f7a7eddb-9a8d-4e93-934b-37425a00affc\",\"type\":\"BoxSelectTool\"},{\"id\":\"ac3e2819-6a07-46d2-8533-d795de4cadcc\",\"type\":\"LassoSelectTool\"},{\"id\":\"20ee64e6-944b-458f-98d0-951a801053f8\",\"type\":\"HelpTool\"},{\"id\":\"731d524a-0200-4d6d-991f-30d18d13a31d\",\"type\":\"BoxSelectTool\"},{\"id\":\"3f05fdf5-2c17-4a1d-995c-c9a63c762801\",\"type\":\"LassoSelectTool\"},{\"id\":\"607c2d48-b279-41ee-93b1-a74d3e0f8d91\",\"type\":\"HelpTool\"}]},\"id\":\"d47becda-70bf-414c-ac76-f0cb16843b13\",\"type\":\"ToolbarBox\"},{\"attributes\":{\"children\":[{\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"af04168e-618d-4a7c-9a65-0a67795a8535\",\"type\":\"Row\"},{\"attributes\":{},\"id\":\"f277dba7-73f5-4c5e-aba0-872a49e83ee7\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"xs_units\":\"screen\",\"ys_units\":\"screen\"},\"id\":\"4e15a3d1-ebbd-464b-a3d5-e6b70d65185b\",\"type\":\"PolyAnnotation\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y0\",\"y1\"],\"data\":{\"x\":[-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],\"y0\":[20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],\"y1\":[400,361,324,289,256,225,196,169,144,121,100,81,64,49,36,25,16,9,4,1,0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225,256,289,324,361,400]}},\"id\":\"c0ee0867-d3b9-43c6-a7e1-cfcdadba848a\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"c0ee0867-d3b9-43c6-a7e1-cfcdadba848a\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"ee28c1be-c113-4103-a62d-fccacf9174eb\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"435efbfa-db40-49ec-a22c-012487e53a07\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"1988003d-2523-4e58-a49a-e7f6fe23fd05\",\"type\":\"CDSView\"}},\"id\":\"0d731b71-369e-41f7-bde6-0b42cec0165f\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"37be03b0-b0c3-4652-83ca-bcc639dc71bd\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y0\"}},\"id\":\"049da368-84dd-4fe9-93bc-adec3836322e\",\"type\":\"Circle\"},{\"attributes\":{\"formatter\":{\"id\":\"49df2086-ceb6-426e-b56d-9761e360adbc\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"fd882a64-4bc4-43e8-a18c-2696ca49811e\",\"type\":\"BasicTicker\"}},\"id\":\"77965d3a-cde2-48cc-a589-cc8e41a3a121\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"fd882a64-4bc4-43e8-a18c-2696ca49811e\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"731d524a-0200-4d6d-991f-30d18d13a31d\",\"type\":\"BoxSelectTool\"},{\"id\":\"3f05fdf5-2c17-4a1d-995c-c9a63c762801\",\"type\":\"LassoSelectTool\"},{\"id\":\"607c2d48-b279-41ee-93b1-a74d3e0f8d91\",\"type\":\"HelpTool\"}]},\"id\":\"e78f65b0-866a-4d06-a457-4beec3ed409b\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null},\"id\":\"0424304c-72d6-4cf0-81d1-240cf179e44c\",\"type\":\"DataRange1d\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"8088eea9-c3d7-42c7-b85b-213e0ae4b4bc\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null,\"overlay\":{\"id\":\"ec4e822d-e5c0-48f8-b8b9-3263a9f0466e\",\"type\":\"BoxAnnotation\"},\"renderers\":[{\"id\":\"53d22ebc-49d7-4683-ae1f-b2e44818bfbc\",\"type\":\"GlyphRenderer\"}]},\"id\":\"f7a7eddb-9a8d-4e93-934b-37425a00affc\",\"type\":\"BoxSelectTool\"},{\"attributes\":{\"source\":{\"id\":\"c0ee0867-d3b9-43c6-a7e1-cfcdadba848a\",\"type\":\"ColumnDataSource\"}},\"id\":\"1988003d-2523-4e58-a49a-e7f6fe23fd05\",\"type\":\"CDSView\"},{\"attributes\":{\"children\":[{\"id\":\"d47becda-70bf-414c-ac76-f0cb16843b13\",\"type\":\"ToolbarBox\"},{\"id\":\"d15d4fae-1d89-4879-94b6-a561e3b75c3b\",\"type\":\"Column\"}]},\"id\":\"60a33f31-850b-44cc-a3e7-885fef66adb3\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"49df2086-ceb6-426e-b56d-9761e360adbc\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"3b1887b2-79c7-45eb-9dae-30382125f20a\",\"type\":\"Title\"},{\"attributes\":{\"below\":[{\"id\":\"77965d3a-cde2-48cc-a589-cc8e41a3a121\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"11c00602-883c-4275-be97-9565e09a683f\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"77965d3a-cde2-48cc-a589-cc8e41a3a121\",\"type\":\"LinearAxis\"},{\"id\":\"8a9beb71-3944-466e-95c6-62e7fda5b83d\",\"type\":\"Grid\"},{\"id\":\"11c00602-883c-4275-be97-9565e09a683f\",\"type\":\"LinearAxis\"},{\"id\":\"8153ac5d-9556-4e82-b330-214943b3ec59\",\"type\":\"Grid\"},{\"id\":\"ec4e822d-e5c0-48f8-b8b9-3263a9f0466e\",\"type\":\"BoxAnnotation\"},{\"id\":\"f15098de-c897-43c9-87bc-de6819613d43\",\"type\":\"PolyAnnotation\"},{\"id\":\"53d22ebc-49d7-4683-ae1f-b2e44818bfbc\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"8088eea9-c3d7-42c7-b85b-213e0ae4b4bc\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"56aaf370-cf91-414c-98ba-6351b20d4bf0\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"678e5b14-005a-45e2-a2c7-9dc0f279e63f\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"b0847014-4209-4537-92b7-a3ce3c5c8605\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"0424304c-72d6-4cf0-81d1-240cf179e44c\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"37be03b0-b0c3-4652-83ca-bcc639dc71bd\",\"type\":\"LinearScale\"}},\"id\":\"fc902bc9-6598-420d-9534-9f2afb8adafc\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null},\"id\":\"678e5b14-005a-45e2-a2c7-9dc0f279e63f\",\"type\":\"DataRange1d\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"xs_units\":\"screen\",\"ys_units\":\"screen\"},\"id\":\"f15098de-c897-43c9-87bc-de6819613d43\",\"type\":\"PolyAnnotation\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"f7a7eddb-9a8d-4e93-934b-37425a00affc\",\"type\":\"BoxSelectTool\"},{\"id\":\"ac3e2819-6a07-46d2-8533-d795de4cadcc\",\"type\":\"LassoSelectTool\"},{\"id\":\"20ee64e6-944b-458f-98d0-951a801053f8\",\"type\":\"HelpTool\"}]},\"id\":\"56aaf370-cf91-414c-98ba-6351b20d4bf0\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1c811fb0-a3c1-4543-a2d3-fb953ba2c68f\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"0fe5b33c-82f3-412e-8ce8-5d213ce809f6\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"ec0008c2-7fc8-4e4e-8a95-b52b8586392c\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"0fe5b33c-82f3-412e-8ce8-5d213ce809f6\",\"type\":\"LinearAxis\"},{\"id\":\"dba3bc7e-b44c-4e9c-b187-f22cf4cbe5c5\",\"type\":\"Grid\"},{\"id\":\"ec0008c2-7fc8-4e4e-8a95-b52b8586392c\",\"type\":\"LinearAxis\"},{\"id\":\"9c112892-b54a-41ff-8d8c-d99c6f4e7ba2\",\"type\":\"Grid\"},{\"id\":\"4efdee2e-1861-4b83-b7f4-d3aba9dbc1b9\",\"type\":\"BoxAnnotation\"},{\"id\":\"4e15a3d1-ebbd-464b-a3d5-e6b70d65185b\",\"type\":\"PolyAnnotation\"},{\"id\":\"0d731b71-369e-41f7-bde6-0b42cec0165f\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"3b1887b2-79c7-45eb-9dae-30382125f20a\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"e78f65b0-866a-4d06-a457-4beec3ed409b\",\"type\":\"Toolbar\"},\"toolbar_location\":null,\"x_range\":{\"id\":\"58bbcbc3-cb84-43d3-b61f-2c51aeaa84b4\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"96a6ad86-50a5-4a4a-8578-b3e32aa3afd5\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"7f11d9e0-7a69-4fe6-ac0a-adbbf3e20f62\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"0396ac7b-b514-4e6e-bfd1-afd015e7def0\",\"type\":\"LinearScale\"}},\"id\":\"f360d448-2814-4d68-bdd9-92dedd55f39c\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y0\"}},\"id\":\"3ae79a1a-a582-4a87-b2d3-4b138d2bb5f6\",\"type\":\"Circle\"},{\"attributes\":{\"children\":[{\"id\":\"af04168e-618d-4a7c-9a65-0a67795a8535\",\"type\":\"Row\"}]},\"id\":\"d15d4fae-1d89-4879-94b6-a561e3b75c3b\",\"type\":\"Column\"}],\"root_ids\":[\"60a33f31-850b-44cc-a3e7-885fef66adb3\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"b614d9ac-c753-4b49-a00f-5b8e8c45b07d\",\"elementid\":\"12cc17fa-a5d6-4d53-8ce3-e4c6707648cf\",\"modelid\":\"60a33f31-850b-44cc-a3e7-885fef66adb3\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "60a33f31-850b-44cc-a3e7-885fef66adb3"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.models import ColumnDataSource\n",
    "\n",
    "x = list(range(-20, 21))\n",
    "y0, y1 = [abs(xx) for xx in x], [xx**2 for xx in x]\n",
    "\n",
    "# create a column data source for the plots to share\n",
    "source = ColumnDataSource(data=dict(x=x, y0=y0, y1=y1))\n",
    "\n",
    "TOOLS = \"box_select,lasso_select,help\"\n",
    "\n",
    "# create a new plot and add a renderer\n",
    "left = figure(tools=TOOLS, width=300, height=300)\n",
    "left.circle('x', 'y0', source=source)\n",
    "\n",
    "# create another new plot and add a renderer\n",
    "right = figure(tools=TOOLS, width=300, height=300)\n",
    "right.circle('x', 'y1', source=source)\n",
    "\n",
    "p = gridplot([[left, right]])\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: create two plots in a gridplot, and link their data sources\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Hover Tools（悬停工具）\n",
    "\n",
    "Bokeh有一个悬停的工具，当用户将鼠标悬停在一个特定的标记符号（glyph）上时，可以在一个弹出框里显示更多的信息。基本的悬停工具配置相当于提供一个 ``(name, format)`` 元组列表。完整的细节请参考用户指南 [hovertool](http://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#hovertool)。\n",
    "\n",
    "下面的例子展示了悬停工的一些基本使用，悬停信息在utils.py中定义："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"77e1c0c1-7bea-4741-a6ce-2525b6fc2720\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"faed8535-927d-41f3-a4bc-cf7cfd25c9bf\":{\"roots\":{\"references\":[{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"62acda0c-5b77-40c9-831c-40449723b846\",\"type\":\"Circle\"},{\"attributes\":{\"plot\":null,\"text\":\"Mouse over the dots\"},\"id\":\"6955621e-2478-4fbc-927a-41abefdb7b4a\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"0c9b979c-577b-483a-8397-402903d6d4ec\",\"type\":\"BasicTicker\"},{\"attributes\":{\"callback\":null},\"id\":\"7215923a-19b2-4fb8-a838-ee9a854e9ec1\",\"type\":\"DataRange1d\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"index\",\"$index\"],[\"(x,y)\",\"($x, $y)\"],[\"desc\",\"@desc\"]]},\"id\":\"52526039-89d5-49ab-8983-0b53b80393d6\",\"type\":\"HoverTool\"},{\"attributes\":{\"callback\":null},\"id\":\"7f37ceb8-4d9c-4e0b-9bfe-bf0ee66e7a40\",\"type\":\"DataRange1d\"},{\"attributes\":{\"formatter\":{\"id\":\"5aa53c56-1e21-4555-9685-030c5f2dbc5c\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0c9b979c-577b-483a-8397-402903d6d4ec\",\"type\":\"BasicTicker\"}},\"id\":\"96a6eaea-b75e-4b7e-a441-09ea85716e5d\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"f8b7d329-71b0-4e1f-ba64-2edb2967272c\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"f2740117-a87e-4546-b4d7-37b45f90c741\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":{\"id\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f8b7d329-71b0-4e1f-ba64-2edb2967272c\",\"type\":\"BasicTicker\"}},\"id\":\"0d7db9d0-80cf-4110-8708-013cded78175\",\"type\":\"Grid\"},{\"attributes\":{\"below\":[{\"id\":\"3adb7f16-a6fb-463d-939f-6d68f68fb7e4\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"96a6eaea-b75e-4b7e-a441-09ea85716e5d\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"3adb7f16-a6fb-463d-939f-6d68f68fb7e4\",\"type\":\"LinearAxis\"},{\"id\":\"0d7db9d0-80cf-4110-8708-013cded78175\",\"type\":\"Grid\"},{\"id\":\"96a6eaea-b75e-4b7e-a441-09ea85716e5d\",\"type\":\"LinearAxis\"},{\"id\":\"df82fc95-7d0d-47d2-8c46-c799c2491847\",\"type\":\"Grid\"},{\"id\":\"047bacbd-d620-44ba-adca-84de2cf7b676\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"6955621e-2478-4fbc-927a-41abefdb7b4a\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"9d776f52-1eff-43b8-9ce3-2976e656a55b\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"7f37ceb8-4d9c-4e0b-9bfe-bf0ee66e7a40\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"b33dcda9-31c1-47b2-93a4-5fca2f007027\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"7215923a-19b2-4fb8-a838-ee9a854e9ec1\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"efe35b47-aeb9-476c-9e4d-87e86174b7ea\",\"type\":\"LinearScale\"}},\"id\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\",\"desc\"],\"data\":{\"desc\":[\"A\",\"b\",\"C\",\"d\",\"E\"],\"x\":[1,2,3,4,5],\"y\":[2,5,8,2,7]}},\"id\":\"ab8071c1-d3ce-4cdc-90e6-422b36f118ee\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"b33dcda9-31c1-47b2-93a4-5fca2f007027\",\"type\":\"LinearScale\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"52526039-89d5-49ab-8983-0b53b80393d6\",\"type\":\"HoverTool\"}]},\"id\":\"9d776f52-1eff-43b8-9ce3-2976e656a55b\",\"type\":\"Toolbar\"},{\"attributes\":{\"formatter\":{\"id\":\"f2740117-a87e-4546-b4d7-37b45f90c741\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"f8b7d329-71b0-4e1f-ba64-2edb2967272c\",\"type\":\"BasicTicker\"}},\"id\":\"3adb7f16-a6fb-463d-939f-6d68f68fb7e4\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"efe35b47-aeb9-476c-9e4d-87e86174b7ea\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"6414aa46-702b-4b2d-9c65-17ad6971b116\",\"type\":\"Circle\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0c9b979c-577b-483a-8397-402903d6d4ec\",\"type\":\"BasicTicker\"}},\"id\":\"df82fc95-7d0d-47d2-8c46-c799c2491847\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"5aa53c56-1e21-4555-9685-030c5f2dbc5c\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"ab8071c1-d3ce-4cdc-90e6-422b36f118ee\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"6414aa46-702b-4b2d-9c65-17ad6971b116\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"62acda0c-5b77-40c9-831c-40449723b846\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"b791675e-1bb8-45bb-b4a3-1e621f04ada6\",\"type\":\"CDSView\"}},\"id\":\"047bacbd-d620-44ba-adca-84de2cf7b676\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"ab8071c1-d3ce-4cdc-90e6-422b36f118ee\",\"type\":\"ColumnDataSource\"}},\"id\":\"b791675e-1bb8-45bb-b4a3-1e621f04ada6\",\"type\":\"CDSView\"}],\"root_ids\":[\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"faed8535-927d-41f3-a4bc-cf7cfd25c9bf\",\"elementid\":\"77e1c0c1-7bea-4741-a6ce-2525b6fc2720\",\"modelid\":\"66cbfd55-b8fc-4eb7-900e-285d75ec6cfb\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "66cbfd55-b8fc-4eb7-900e-285d75ec6cfb"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.models import HoverTool\n",
    "\n",
    "source = ColumnDataSource(\n",
    "        data=dict(\n",
    "            x=[1, 2, 3, 4, 5],\n",
    "            y=[2, 5, 8, 2, 7],\n",
    "            desc=['A', 'b', 'C', 'd', 'E'],\n",
    "        )\n",
    "    )\n",
    "\n",
    "hover = HoverTool(\n",
    "        tooltips=[\n",
    "            (\"index\", \"$index\"),\n",
    "            (\"(x,y)\", \"($x, $y)\"),\n",
    "            (\"desc\", \"@desc\"),\n",
    "        ]\n",
    "    )\n",
    "\n",
    "p = figure(plot_width=300, plot_height=300, tools=[hover], title=\"Mouse over the dots\")\n",
    "\n",
    "p.circle('x', 'y', size=20, source=source)\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Widgets（控件）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Bokeh直接集成了一个小的基本控件集。这些控件和Bokeh服务器或 ``CustomJS`` 模型协作使用可以加入更多的互动的功能。您可以在用户指南的 [Adding Widgets](http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html#adding-widgets) 部分看到完整的widget列表和示例代码。\n",
    "\n",
    "要使用小部件，就像您将使用一个绘图对象一样，将它们包括在布局中："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"a42aa936-e073-4ac3-a67b-df0a083594f0\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"760f442f-bf28-4127-bd0a-67f2e7ca8da4\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null,\"end\":10,\"start\":0,\"step\":0.1,\"title\":\"foo\",\"value\":1},\"id\":\"72cf5c3d-3412-4080-bf35-44d8db1d69d7\",\"type\":\"Slider\"},{\"attributes\":{\"children\":[{\"id\":\"72cf5c3d-3412-4080-bf35-44d8db1d69d7\",\"type\":\"Slider\"}]},\"id\":\"dec7a124-e863-4f7e-aba0-e25ddd9cb66c\",\"type\":\"WidgetBox\"}],\"root_ids\":[\"dec7a124-e863-4f7e-aba0-e25ddd9cb66c\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"760f442f-bf28-4127-bd0a-67f2e7ca8da4\",\"elementid\":\"a42aa936-e073-4ac3-a67b-df0a083594f0\",\"modelid\":\"dec7a124-e863-4f7e-aba0-e25ddd9cb66c\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "dec7a124-e863-4f7e-aba0-e25ddd9cb66c"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.layouts import widgetbox\n",
    "from bokeh.models.widgets import Slider\n",
    "\n",
    "\n",
    "slider = Slider(start=0, end=10, value=1, step=.1, title=\"foo\")\n",
    "\n",
    "show(widgetbox(slider))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# EXERCISE: create and show a Select widget \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CustomJS Callbacks（CustomJS回调）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"c5a2d607-3e29-4350-b863-f38cd8c1c364\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"880e9c16-4b04-4dea-9b82-e6711d1f3c3f\":{\"roots\":{\"references\":[{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"ab1a5ddb-55df-451a-bafc-87c824fbcd98\",\"type\":\"Circle\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"6b852845-d4ae-4341-8798-83ca02fa9b24\",\"type\":\"TapTool\"}]},\"id\":\"e4c77ae8-077b-476a-ae75-fa46ad7dd10f\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1bb3a5a6-17b2-463d-8034-0c9df4c67804\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"data_source\":{\"id\":\"bb3ff864-24cb-4baf-aeff-d692f3130682\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"ab1a5ddb-55df-451a-bafc-87c824fbcd98\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"48b38e17-d1d6-441e-bd6e-00c97723a8da\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"ae8ad91a-9a14-48f7-b279-188106e562f4\",\"type\":\"CDSView\"}},\"id\":\"7e35ae0d-d008-4d77-b017-74f2f5f8c282\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"7e07385a-4bcf-470e-908a-883e20e1ffee\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[1,2,3,4,5],\"y\":[2,5,8,2,7]}},\"id\":\"bb3ff864-24cb-4baf-aeff-d692f3130682\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"below\":[{\"id\":\"5b6390ab-8dfc-4d12-b285-a8017d9dfa28\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"13ce64e1-eabc-44b9-9ebd-8e889013a39a\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"renderers\":[{\"id\":\"5b6390ab-8dfc-4d12-b285-a8017d9dfa28\",\"type\":\"LinearAxis\"},{\"id\":\"6acd5dfe-5da5-4616-b6f4-2d5e1c026b02\",\"type\":\"Grid\"},{\"id\":\"13ce64e1-eabc-44b9-9ebd-8e889013a39a\",\"type\":\"LinearAxis\"},{\"id\":\"83f8f904-2922-4184-9d89-e640a7b55cdb\",\"type\":\"Grid\"},{\"id\":\"7e35ae0d-d008-4d77-b017-74f2f5f8c282\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"72290c05-61f7-4682-8a3a-cd49393ccc81\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"e4c77ae8-077b-476a-ae75-fa46ad7dd10f\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"2680342a-cf95-48fc-b393-e8c51d66bc6d\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"1edbf06a-82b6-4b8f-9ceb-054b228f47fa\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"957d69dd-6851-4a8a-bc3e-054735699cef\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"7e07385a-4bcf-470e-908a-883e20e1ffee\",\"type\":\"LinearScale\"}},\"id\":\"58953124-dd20-4bdb-b072-d5c8722797bd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":20},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"48b38e17-d1d6-441e-bd6e-00c97723a8da\",\"type\":\"Circle\"},{\"attributes\":{\"code\":\"alert('hello world')\"},\"id\":\"f0c90a90-d0d0-4bb8-a944-f0d9e6133f13\",\"type\":\"CustomJS\"},{\"attributes\":{\"callback\":null},\"id\":\"957d69dd-6851-4a8a-bc3e-054735699cef\",\"type\":\"DataRange1d\"},{\"attributes\":{\"formatter\":{\"id\":\"1bb3a5a6-17b2-463d-8034-0c9df4c67804\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"58953124-dd20-4bdb-b072-d5c8722797bd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"41e86e84-684f-42f4-907f-875e36ecbedc\",\"type\":\"BasicTicker\"}},\"id\":\"5b6390ab-8dfc-4d12-b285-a8017d9dfa28\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"928d9c4f-2e17-43e5-85f4-3b775d14d853\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1edbf06a-82b6-4b8f-9ceb-054b228f47fa\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"2680342a-cf95-48fc-b393-e8c51d66bc6d\",\"type\":\"DataRange1d\"},{\"attributes\":{\"formatter\":{\"id\":\"510b3c6d-7142-455c-9bfa-769458c20a06\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"58953124-dd20-4bdb-b072-d5c8722797bd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"928d9c4f-2e17-43e5-85f4-3b775d14d853\",\"type\":\"BasicTicker\"}},\"id\":\"13ce64e1-eabc-44b9-9ebd-8e889013a39a\",\"type\":\"LinearAxis\"},{\"attributes\":{\"source\":{\"id\":\"bb3ff864-24cb-4baf-aeff-d692f3130682\",\"type\":\"ColumnDataSource\"}},\"id\":\"ae8ad91a-9a14-48f7-b279-188106e562f4\",\"type\":\"CDSView\"},{\"attributes\":{\"plot\":{\"id\":\"58953124-dd20-4bdb-b072-d5c8722797bd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"41e86e84-684f-42f4-907f-875e36ecbedc\",\"type\":\"BasicTicker\"}},\"id\":\"6acd5dfe-5da5-4616-b6f4-2d5e1c026b02\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"510b3c6d-7142-455c-9bfa-769458c20a06\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"callback\":{\"id\":\"f0c90a90-d0d0-4bb8-a944-f0d9e6133f13\",\"type\":\"CustomJS\"}},\"id\":\"6b852845-d4ae-4341-8798-83ca02fa9b24\",\"type\":\"TapTool\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"72290c05-61f7-4682-8a3a-cd49393ccc81\",\"type\":\"Title\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"58953124-dd20-4bdb-b072-d5c8722797bd\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"928d9c4f-2e17-43e5-85f4-3b775d14d853\",\"type\":\"BasicTicker\"}},\"id\":\"83f8f904-2922-4184-9d89-e640a7b55cdb\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"41e86e84-684f-42f4-907f-875e36ecbedc\",\"type\":\"BasicTicker\"}],\"root_ids\":[\"58953124-dd20-4bdb-b072-d5c8722797bd\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"880e9c16-4b04-4dea-9b82-e6711d1f3c3f\",\"elementid\":\"c5a2d607-3e29-4350-b863-f38cd8c1c364\",\"modelid\":\"58953124-dd20-4bdb-b072-d5c8722797bd\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "58953124-dd20-4bdb-b072-d5c8722797bd"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.models import TapTool, CustomJS, ColumnDataSource\n",
    "\n",
    "callback = CustomJS(code=\"alert('hello world')\")\n",
    "tap = TapTool(callback=callback)\n",
    "\n",
    "p = figure(plot_width=600, plot_height=300, tools=[tap])\n",
    "\n",
    "p.circle(x=[1, 2, 3, 4, 5], y=[2, 5, 8, 2, 7], size=20)\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 很多地方可以添加回调\n",
    "\n",
    "* Widgets - Button, Toggle, Dropdown, TextInput, AutocompleteInput, Select, Multiselect, Slider, (DateRangeSlider), DatePicker,\n",
    "* Tools - TapTool, BoxSelectTool, HoverTool,\n",
    "* Selection - ColumnDataSource, AjaxDataSource, BlazeDataSource, ServerDataSource\n",
    "* Ranges - Range1d, DataRange1d, FactorRange\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Callbacks for widgets（控件的回调）\n",
    "\n",
    "具有关联值的控件可以附上小的JavaScript动作。这些动作（也被称为“回调”）在控件的值改变时被执行。为了更容易从JavaScript引用特定的Bokeh模型（例如，数据源或标记符），``CustomJS`` 对象接受一个dictionary类型的“参数”，映射名字到Bokeh模型。对应的JavaScript模型自动提供给 ``CustomJS`` 代码。\n",
    "\n",
    "下面的例子展示了一个附加到滑块的动作，滑块每次移动时都会更新数据源："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"52874044-5004-4343-9fef-7edaca451776\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"45c4b7d1-177f-4b8c-9239-7cc4b52b06c6\":{\"roots\":{\"references\":[{\"attributes\":{},\"id\":\"0fed51ec-1590-4f84-b30f-c7c78ae8c02e\",\"type\":\"BasicTicker\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0fed51ec-1590-4f84-b30f-c7c78ae8c02e\",\"type\":\"BasicTicker\"}},\"id\":\"19485943-5468-4e31-ac7d-5b6af7bf6376\",\"type\":\"Grid\"},{\"attributes\":{\"source\":{\"id\":\"c4a483f4-42a4-4d34-9d6a-5f61f734d382\",\"type\":\"ColumnDataSource\"}},\"id\":\"fbbd0d22-baab-4909-ae5b-710735d3e9b1\",\"type\":\"CDSView\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":3},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"a2e13630-28b6-4caa-8baf-f08a0f2f6133\",\"type\":\"Line\"},{\"attributes\":{\"below\":[{\"id\":\"cfc2adeb-7dee-4787-85ec-c4c211e463b0\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"d4d981ca-80a0-4fd2-b648-9aa5a5f17d8e\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"cfc2adeb-7dee-4787-85ec-c4c211e463b0\",\"type\":\"LinearAxis\"},{\"id\":\"0c287713-5686-4364-9822-7a32d487f567\",\"type\":\"Grid\"},{\"id\":\"d4d981ca-80a0-4fd2-b648-9aa5a5f17d8e\",\"type\":\"LinearAxis\"},{\"id\":\"19485943-5468-4e31-ac7d-5b6af7bf6376\",\"type\":\"Grid\"},{\"id\":\"3e0ca6c2-54d8-4b3b-acee-74a7cce4d0a7\",\"type\":\"BoxAnnotation\"},{\"id\":\"e7cd0e3a-b398-4847-adbf-ecd409781db9\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"3a2fa010-2f5c-45b0-9c00-b95510d3f392\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"b3d5ccfb-02ab-49e8-b261-bb10ebbcb1ed\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"b56cc2e2-621a-4ef7-897a-c3754441f39e\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"bf6df5c3-79b7-4ab1-8165-251090bffab7\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"71494432-0f43-461a-9cbd-8a5fc7da0438\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"9c67195a-0d1c-4fa9-aeed-f9c34188a344\",\"type\":\"LinearScale\"}},\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"line_alpha\":{\"value\":0.6},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":3},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"646e4ec8-9325-434e-b053-abe7eed29338\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"e60521f9-61f8-439f-9695-126f8c3504f4\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"children\":[{\"id\":\"32ea869f-8d87-4117-a87e-631c4f1ce0bd\",\"type\":\"WidgetBox\"},{\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"}]},\"id\":\"a2cec057-9aba-4eb3-85f0-ba3e50d9d1ae\",\"type\":\"Column\"},{\"attributes\":{},\"id\":\"9596f59f-7e02-4874-90ef-1c5dd02bb674\",\"type\":\"PanTool\"},{\"attributes\":{},\"id\":\"2d7ab4dc-d694-4649-be2f-40e8dc9ca905\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"3a2fa010-2f5c-45b0-9c00-b95510d3f392\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"x\",\"y\"],\"data\":{\"x\":[0.0,0.005,0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.075,0.08,0.085,0.09,0.095,0.1,0.105,0.11,0.115,0.12,0.125,0.13,0.135,0.14,0.145,0.15,0.155,0.16,0.165,0.17,0.17500000000000002,0.18,0.185,0.19,0.195,0.2,0.20500000000000002,0.21,0.215,0.22,0.225,0.23,0.23500000000000001,0.24,0.245,0.25,0.255,0.26,0.265,0.27,0.275,0.28,0.28500000000000003,0.29,0.295,0.3,0.305,0.31,0.315,0.32,0.325,0.33,0.335,0.34,0.34500000000000003,0.35000000000000003,0.355,0.36,0.365,0.37,0.375,0.38,0.385,0.39,0.395,0.4,0.405,0.41000000000000003,0.41500000000000004,0.42,0.425,0.43,0.435,0.44,0.445,0.45,0.455,0.46,0.465,0.47000000000000003,0.47500000000000003,0.48,0.485,0.49,0.495,0.5,0.505,0.51,0.515,0.52,0.525,0.53,0.535,0.54,0.545,0.55,0.555,0.56,0.5650000000000001,0.5700000000000001,0.5750000000000001,0.58,0.585,0.59,0.595,0.6,0.605,0.61,0.615,0.62,0.625,0.63,0.635,0.64,0.645,0.65,0.655,0.66,0.665,0.67,0.675,0.68,0.685,0.6900000000000001,0.6950000000000001,0.7000000000000001,0.705,0.71,0.715,0.72,0.725,0.73,0.735,0.74,0.745,0.75,0.755,0.76,0.765,0.77,0.775,0.78,0.785,0.79,0.795,0.8,0.805,0.81,0.8150000000000001,0.8200000000000001,0.8250000000000001,0.8300000000000001,0.835,0.84,0.845,0.85,0.855,0.86,0.865,0.87,0.875,0.88,0.885,0.89,0.895,0.9,0.905,0.91,0.915,0.92,0.925,0.93,0.935,0.9400000000000001,0.9450000000000001,0.9500000000000001,0.9550000000000001,0.96,0.965,0.97,0.975,0.98,0.985,0.99,0.995,1.0],\"y\":[0.0,0.005,0.01,0.015,0.02,0.025,0.03,0.035,0.04,0.045,0.05,0.055,0.06,0.065,0.07,0.075,0.08,0.085,0.09,0.095,0.1,0.105,0.11,0.115,0.12,0.125,0.13,0.135,0.14,0.145,0.15,0.155,0.16,0.165,0.17,0.17500000000000002,0.18,0.185,0.19,0.195,0.2,0.20500000000000002,0.21,0.215,0.22,0.225,0.23,0.23500000000000001,0.24,0.245,0.25,0.255,0.26,0.265,0.27,0.275,0.28,0.28500000000000003,0.29,0.295,0.3,0.305,0.31,0.315,0.32,0.325,0.33,0.335,0.34,0.34500000000000003,0.35000000000000003,0.355,0.36,0.365,0.37,0.375,0.38,0.385,0.39,0.395,0.4,0.405,0.41000000000000003,0.41500000000000004,0.42,0.425,0.43,0.435,0.44,0.445,0.45,0.455,0.46,0.465,0.47000000000000003,0.47500000000000003,0.48,0.485,0.49,0.495,0.5,0.505,0.51,0.515,0.52,0.525,0.53,0.535,0.54,0.545,0.55,0.555,0.56,0.5650000000000001,0.5700000000000001,0.5750000000000001,0.58,0.585,0.59,0.595,0.6,0.605,0.61,0.615,0.62,0.625,0.63,0.635,0.64,0.645,0.65,0.655,0.66,0.665,0.67,0.675,0.68,0.685,0.6900000000000001,0.6950000000000001,0.7000000000000001,0.705,0.71,0.715,0.72,0.725,0.73,0.735,0.74,0.745,0.75,0.755,0.76,0.765,0.77,0.775,0.78,0.785,0.79,0.795,0.8,0.805,0.81,0.8150000000000001,0.8200000000000001,0.8250000000000001,0.8300000000000001,0.835,0.84,0.845,0.85,0.855,0.86,0.865,0.87,0.875,0.88,0.885,0.89,0.895,0.9,0.905,0.91,0.915,0.92,0.925,0.93,0.935,0.9400000000000001,0.9450000000000001,0.9500000000000001,0.9550000000000001,0.96,0.965,0.97,0.975,0.98,0.985,0.99,0.995,1.0]}},\"id\":\"c4a483f4-42a4-4d34-9d6a-5f61f734d382\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"bffa7794-7fb0-455c-9f10-c11be0e86205\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"9596f59f-7e02-4874-90ef-1c5dd02bb674\",\"type\":\"PanTool\"},{\"id\":\"bffa7794-7fb0-455c-9f10-c11be0e86205\",\"type\":\"WheelZoomTool\"},{\"id\":\"dc5306ac-cf61-43b5-bc22-6a711a88e2aa\",\"type\":\"BoxZoomTool\"},{\"id\":\"4277a383-1779-4df9-80a5-b1a4eafa1136\",\"type\":\"SaveTool\"},{\"id\":\"a84600e6-93b0-4516-881e-4cbb3b5de8c6\",\"type\":\"ResetTool\"},{\"id\":\"53294a06-a2ed-4703-93a3-c25dc2fea221\",\"type\":\"HelpTool\"}]},\"id\":\"b3d5ccfb-02ab-49e8-b261-bb10ebbcb1ed\",\"type\":\"Toolbar\"},{\"attributes\":{\"overlay\":{\"id\":\"3e0ca6c2-54d8-4b3b-acee-74a7cce4d0a7\",\"type\":\"BoxAnnotation\"}},\"id\":\"dc5306ac-cf61-43b5-bc22-6a711a88e2aa\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"callback\":null},\"id\":\"b56cc2e2-621a-4ef7-897a-c3754441f39e\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"4277a383-1779-4df9-80a5-b1a4eafa1136\",\"type\":\"SaveTool\"},{\"attributes\":{\"data_source\":{\"id\":\"c4a483f4-42a4-4d34-9d6a-5f61f734d382\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"646e4ec8-9325-434e-b053-abe7eed29338\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"a2e13630-28b6-4caa-8baf-f08a0f2f6133\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"fbbd0d22-baab-4909-ae5b-710735d3e9b1\",\"type\":\"CDSView\"}},\"id\":\"e7cd0e3a-b398-4847-adbf-ecd409781db9\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"a84600e6-93b0-4516-881e-4cbb3b5de8c6\",\"type\":\"ResetTool\"},{\"attributes\":{\"callback\":null},\"id\":\"71494432-0f43-461a-9cbd-8a5fc7da0438\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"53294a06-a2ed-4703-93a3-c25dc2fea221\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"bf6df5c3-79b7-4ab1-8165-251090bffab7\",\"type\":\"LinearScale\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"render_mode\":\"css\",\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"3e0ca6c2-54d8-4b3b-acee-74a7cce4d0a7\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"9c67195a-0d1c-4fa9-aeed-f9c34188a344\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"end\":6,\"js_property_callbacks\":{\"change:value\":[{\"id\":\"3068f4ae-05db-4a08-aaf0-f142d9e139df\",\"type\":\"CustomJS\"}]},\"start\":0.1,\"step\":0.1,\"title\":\"power\",\"value\":1},\"id\":\"f93444cb-79f4-40a7-8c8a-05e1d91088be\",\"type\":\"Slider\"},{\"attributes\":{\"plot\":{\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d67a28af-53b2-461b-b0c6-373e1606a529\",\"type\":\"BasicTicker\"}},\"id\":\"0c287713-5686-4364-9822-7a32d487f567\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"2d7ab4dc-d694-4649-be2f-40e8dc9ca905\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"d67a28af-53b2-461b-b0c6-373e1606a529\",\"type\":\"BasicTicker\"}},\"id\":\"cfc2adeb-7dee-4787-85ec-c4c211e463b0\",\"type\":\"LinearAxis\"},{\"attributes\":{\"children\":[{\"id\":\"f93444cb-79f4-40a7-8c8a-05e1d91088be\",\"type\":\"Slider\"}]},\"id\":\"32ea869f-8d87-4117-a87e-631c4f1ce0bd\",\"type\":\"WidgetBox\"},{\"attributes\":{},\"id\":\"d67a28af-53b2-461b-b0c6-373e1606a529\",\"type\":\"BasicTicker\"},{\"attributes\":{\"args\":{\"slider\":{\"id\":\"f93444cb-79f4-40a7-8c8a-05e1d91088be\",\"type\":\"Slider\"},\"source\":{\"id\":\"c4a483f4-42a4-4d34-9d6a-5f61f734d382\",\"type\":\"ColumnDataSource\"}},\"code\":\"\\n    var data = source.get('data');\\n    var f = slider.value;\\n    x = data['x']\\n    y = data['y']\\n    for (i = 0; i < x.length; i++) {\\n        y[i] = Math.pow(x[i], f)\\n    }\\n    source.change.emit();\\n\"},\"id\":\"3068f4ae-05db-4a08-aaf0-f142d9e139df\",\"type\":\"CustomJS\"},{\"attributes\":{\"formatter\":{\"id\":\"e60521f9-61f8-439f-9695-126f8c3504f4\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"7ed14616-423f-4999-bad9-54ba31f038ef\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"0fed51ec-1590-4f84-b30f-c7c78ae8c02e\",\"type\":\"BasicTicker\"}},\"id\":\"d4d981ca-80a0-4fd2-b648-9aa5a5f17d8e\",\"type\":\"LinearAxis\"}],\"root_ids\":[\"a2cec057-9aba-4eb3-85f0-ba3e50d9d1ae\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"45c4b7d1-177f-4b8c-9239-7cc4b52b06c6\",\"elementid\":\"52874044-5004-4343-9fef-7edaca451776\",\"modelid\":\"a2cec057-9aba-4eb3-85f0-ba3e50d9d1ae\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "a2cec057-9aba-4eb3-85f0-ba3e50d9d1ae"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from bokeh.layouts import column\n",
    "from bokeh.models import CustomJS, ColumnDataSource, Slider\n",
    "\n",
    "x = [x*0.005 for x in range(0, 201)]\n",
    "\n",
    "source = ColumnDataSource(data=dict(x=x, y=x))\n",
    "\n",
    "plot = figure(plot_width=400, plot_height=400)\n",
    "plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)\n",
    "\n",
    "slider = Slider(start=0.1, end=6, value=1, step=.1, title=\"power\")\n",
    "\n",
    "update_curve = CustomJS(args=dict(source=source, slider=slider), code=\"\"\"\n",
    "    var data = source.get('data');\n",
    "    var f = slider.value;\n",
    "    x = data['x']\n",
    "    y = data['y']\n",
    "    for (i = 0; i < x.length; i++) {\n",
    "        y[i] = Math.pow(x[i], f)\n",
    "    }\n",
    "    source.change.emit();\n",
    "\"\"\")\n",
    "slider.js_on_change('value', update_curve)\n",
    "\n",
    "\n",
    "show(column(slider, plot))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calbacks for selections（选择的回调）\n",
    "\n",
    "也可以在用户选择（例如，框、点、套索）更改时执行JavaScript动作。这是通过将同样的customjs对象附加到要选择的数据源实现的。\n",
    "\n",
    "下面的示例稍稍复杂，展示通过响应一个标记符的选择来更新另一个标记符的数据源："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<div class=\"bk-root\">\n",
       "    <div class=\"bk-plotdiv\" id=\"3e2a996c-45cb-4d93-bc5d-0a1ee0ac2129\"></div>\n",
       "</div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/javascript": [
       "(function(root) {\n",
       "  function embed_document(root) {\n",
       "    var docs_json = {\"e9031398-3da1-4fa3-9cfe-48a29194674d\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null},\"id\":\"22ee51a5-8b12-4e80-a68d-9d7e6fbc5229\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"5afb3e8b-a079-42a9-8885-96799f5884b4\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null},\"id\":\"1866a425-d79c-4b4f-9b1b-789bdd33ce8a\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"d58121ea-1d22-45bf-991f-341fee564f8d\",\"type\":\"LinearScale\"},{\"attributes\":{\"plot\":null,\"text\":\"Select Here\"},\"id\":\"244314f4-cb14-45b7-95fd-b31b515e8251\",\"type\":\"Title\"},{\"attributes\":{\"args\":{\"s2\":{\"id\":\"4b64acfb-e8fd-4d1f-8f1b-bf8c9e3734f9\",\"type\":\"ColumnDataSource\"}},\"code\":\"\\n    var inds = cb_obj.get('selected')['1d'].indices;\\n    var d = cb_obj.get('data');\\n    var ym = 0\\n    \\n    if (inds.length == 0) { return; }\\n    \\n    for (i = 0; i < d['color'].length; i++) {\\n        d['color'][i] = \\\"navy\\\"\\n    }\\n    for (i = 0; i < inds.length; i++) {\\n        d['color'][inds[i]] = \\\"firebrick\\\"\\n        ym += d['y'][inds[i]]\\n    }\\n    \\n    ym /= inds.length\\n    s2.get('data')['ym'] = [ym, ym]\\n    \\n    cb_obj.trigger('change');\\n    s2.trigger('change');\\n\"},\"id\":\"10d0ffb2-6f3c-4aac-b0c4-a2616312a363\",\"type\":\"CustomJS\"},{\"attributes\":{\"plot\":{\"id\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"51c0ad27-c0ea-4bba-817c-233a03cf6e5e\",\"type\":\"BasicTicker\"}},\"id\":\"3c733c27-0be1-4820-8c16-08911534d0f9\",\"type\":\"Grid\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.4},\"fill_color\":{\"field\":\"color\"},\"line_alpha\":{\"value\":0.4},\"line_color\":{\"field\":\"color\"},\"size\":{\"units\":\"screen\",\"value\":8},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"bd87463c-ff51-44c7-8afa-036665eb540d\",\"type\":\"Circle\"},{\"attributes\":{\"line_alpha\":{\"value\":0.6},\"line_color\":{\"value\":\"orange\"},\"line_width\":{\"value\":5},\"x\":{\"field\":\"xm\"},\"y\":{\"field\":\"ym\"}},\"id\":\"828245e1-78fc-491a-ad8c-5de71fb48337\",\"type\":\"Line\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"8a7a17f5-7303-48b0-ae1a-d54dc2b9ed5b\",\"type\":\"LassoSelectTool\"}]},\"id\":\"e98d1b3a-b36d-440c-8104-090f72e93bd2\",\"type\":\"Toolbar\"},{\"attributes\":{\"callback\":null,\"overlay\":{\"id\":\"04e8eb75-f8c8-4467-8a4c-d4d8ecf53d9d\",\"type\":\"PolyAnnotation\"}},\"id\":\"8a7a17f5-7303-48b0-ae1a-d54dc2b9ed5b\",\"type\":\"LassoSelectTool\"},{\"attributes\":{},\"id\":\"a358809a-1a3f-4506-9faa-182c37113e51\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"source\":{\"id\":\"4b64acfb-e8fd-4d1f-8f1b-bf8c9e3734f9\",\"type\":\"ColumnDataSource\"}},\"id\":\"bce2c547-052c-4b61-b3ba-46ee0fd8a06a\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"size\":{\"units\":\"screen\",\"value\":8},\"x\":{\"field\":\"x\"},\"y\":{\"field\":\"y\"}},\"id\":\"12b0437a-5702-455e-8c05-f2b4677ebbf5\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"51c0ad27-c0ea-4bba-817c-233a03cf6e5e\",\"type\":\"BasicTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"4b5b4894-0008-4a2d-b236-9290dbf05ecd\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c24e2bb1-91f5-413a-b597-193c78e350f4\",\"type\":\"BasicTicker\"}},\"id\":\"098ef1e5-7460-41ad-afba-e402eb45c877\",\"type\":\"LinearAxis\"},{\"attributes\":{\"data_source\":{\"id\":\"f8c26d6c-b6a0-449f-8f34-51651453c19e\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"bd87463c-ff51-44c7-8afa-036665eb540d\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"12b0437a-5702-455e-8c05-f2b4677ebbf5\",\"type\":\"Circle\"},\"selection_glyph\":null,\"view\":{\"id\":\"664e9a0e-92aa-43af-8f42-603c3cd60c1c\",\"type\":\"CDSView\"}},\"id\":\"bdb9dba1-0262-42e5-929e-feaf13e5df2c\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":{\"id\":\"10d0ffb2-6f3c-4aac-b0c4-a2616312a363\",\"type\":\"CustomJS\"},\"column_names\":[\"x\",\"y\",\"color\"],\"data\":{\"color\":[\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\",\"navy\"],\"x\":[0.7552112002701526,0.3669174515704837,0.17159193673317252,0.03161225629692199,0.7617988731128941,0.688560012943457,0.30082982966573,0.20317855311290212,0.5865945409622718,0.20952853575017782,0.4401956834447711,0.32535012480372005,0.3716448634038355,0.240810373331526,0.10190483546896756,0.894356367300907,0.706352134585289,0.1376800452988084,0.07585532505402925,0.8033995576635741,0.09380818368406929,0.9107467940513205,0.03437234468999206,0.5849698984219452,0.9734300569696761,0.31182078457866735,0.5189753783322362,0.9776369916411787,0.6370707230449925,0.8731414725588688,0.26791396628893516,0.3002422412704301,0.9844048620968262,0.004032197109759328,0.8800941149566582,0.08488933666832776,0.8009479365647074,0.5826974652634361,0.5933865079555385,0.9599469770810851,0.700982435162404,0.9406622689485827,0.12585804113237042,0.04783234442457873,0.9408711041645343,0.23372878049358825,0.14027504625291942,0.3124526400115839,0.2671630776655176,0.6099825054020596,0.8747412027515654,0.16571002136516966,0.47898925940081205,0.5166657483772038,0.7081035167732415,0.3943650305781986,0.2680788036363638,0.9387987790346132,0.6584815630243162,0.6294010137380494,0.14448801293376012,0.8419227333632873,0.29319819600541996,0.9295131657888468,0.5631922309094064,0.14030492600188538,0.8212439336555474,0.8956082018546044,0.9117672049393775,0.8716321123147186,0.5383773677448347,0.09922284732710906,0.14190975797586947,0.4758466025041782,0.3585564184759986,0.7425620036390941,0.22208622260821587,0.5839837799335671,0.007184484558901416,0.4826223085305682,0.2787740057060707,0.14761356800081538,0.2252258523510946,0.9221227624600931,0.4994385960879397,0.9114050854323076,0.6829598528350542,0.20196993376339156,0.3703787106218789,0.9753652316977093,0.06838100680117531,0.3229533486982915,0.048392984063911126,0.2718264991774988,0.4221797169828647,0.26341090542671874,0.046338262198189706,0.041262987005719176,0.3954827636082263,0.578005640586315,0.058684467786155436,0.5867711929504791,0.2558434132111418,0.32474122790919224,0.6039561163254835,0.6516952569349864,0.6607323734562175,0.06599733841813016,0.6387233248960397,0.6353707457069795,0.6595490610902391,0.7776299676971052,0.5330453507098972,0.3887042968069244,0.37409507272157105,0.8610440307596218,0.44399399980443643,0.043237490127113976,0.0960734161352007,0.047109270075451626,0.8075614428752634,0.2672336493627625,0.3845671462541328,0.2757921105893646,0.3397400656034544,0.9337905812481155,0.2845473184230347,0.5755107671672883,0.5228684042059317,0.6031429527272246,0.0711465753700471,0.13603899162255306,0.3472012954677107,0.4586336134089112,0.25653748434868573,0.8740915552643942,0.17049966137055028,0.8715452280458719,0.0795324179731901,0.40616569304007066,0.7768884904064353,0.7707885516658993,0.16665922497941277,0.5742811379724874,0.8565902516922693,0.9623882501949061,0.35500927492419854,0.09957658611933196,0.17295838769000382,0.2738543828370059,0.08292266250411917,0.6995814846397018,0.2747171613461251,0.15356428349875806,0.998244785858323,0.7194960920642294,0.4691259703226742,0.6592439191561641,0.6118304658248453,0.9756041796771497,0.3294046538981098,0.5133440447845126,0.4592363100753709,0.5994224862454816,0.7612924645202407,0.17048304959947658,0.09058557918597498,0.23670555967935203,0.6929321410231506,0.6991192894311753,0.9787224854374349,0.045085480265544375,0.8011681226575375,0.634655238534243,0.9059432323939541,0.14342122683837688,0.5928187446014813,0.1608169040591756,0.4568205490234748,0.706935784105979,0.9341021439543663,0.1893054953642478,0.47004108322585236,0.1848784768406747,0.5991343890241145,0.9168192697807142,0.3364524012558745,0.8400338101645342,0.2701087151395276,0.9465229754866726,0.9120254057336274,0.9770354107370395,0.7429873370490162,0.7909200662936868,0.9404193756585894,0.9600631427489937,0.7795293850426532,0.8880827232938407,0.032019448540437034,0.42549367733667554,0.235346971092536,0.9971772048380719,0.2711799430251346,0.855964233272535,0.2926151160023257,0.28693603532785317,0.2840244770326221,0.6897190003969547,0.8690243594572072,0.1331116667861053,0.424078737265024,0.1126905595645259,0.7268585618761736,0.5260438151266204,0.838084023167381,0.944372917069993,0.9605334773581568,0.5269336846532543,0.9252468108316991,0.09394593035701071,0.020391327332580422,0.7173435166610244,0.8453429070232201,0.3938486318546711,0.9454721222170746,0.14821312709982581,0.6802940327800227,0.5564457946547258,0.9960621618226984,0.3068741988969991,0.025096795114563086,0.8436598268573021,0.2782081723871376,0.11456204916741297,0.1407059182530339,0.6174900054014282,0.8657676728255166,0.8743919698299073,0.6253234245177942,0.32159070543264945,0.08452831681361972,0.36053302154808886,0.8681691655553653,0.5856964006344301,0.13465405761923155,0.3101529811211027,0.32470355534911655,0.14463018687554507,0.23418449408321218,0.027242794595988107,0.6207201887395881,0.18194316705144575,0.37845916954500014,0.9551144711834503,0.5137279450166128,0.3075700763362432,0.813911306790144,0.8620627236958147,0.8972713877700841,0.3022676581120721,0.6402251760990212,0.7249520341699545,0.2479685439464836,0.706179561944295,0.34383046138443285,0.03806533643324794,0.8084218074060836,0.10399181716293526,0.9604313044480962,0.736602922927025,0.8546474970295327,0.2513501007886325,0.15624264193005566,0.06433590589330751,0.4919956442245873,0.5835776459995371,0.7990907187459557,0.9898434293506255,0.3699628486406419,0.10433867783930806,0.6301426989828041,0.7093173134350533,0.8168656287033375,0.11447209437221517,0.8407738038091184,0.23285970936472988,0.013785692302171637,0.8537399959728889,0.7251054123926743,0.40033875574456645,0.33316117931568034,0.8039855674559511,0.5201950503311124,0.5706931632178288,0.33191163009204994,0.021344471584670344,0.4641427418184707,0.6758836229716929,0.9315707926522508,0.3267066088054462,0.6856920639303158,0.7408770571566167,0.6115355906833173,0.43657110713064307,0.3602896760031946,0.9677714693951786,0.1793400238849321,0.7391072237626121,0.13922805415721617,0.26382098895436956,0.4538866648613007,0.15963538433118019,0.8266173357640993,0.4597970460328923,0.32961182849571025,0.42773542471178494,0.22191025326250724,0.19972470341535076,0.6162518413996148,0.06967181215650986,0.9995485601541866,0.9401282730341074,0.269992767834519,0.7832808511003598,0.275823048004292,0.5030268088805689,0.6247115138480075,0.5922162524475945,0.5483682928581254,0.18987600883534272,0.7220876810821337,0.8144030928065038,0.34331661326107965,0.9065799782667887,0.8682957643965303,0.7935937206788419,0.9225987838768295,0.805311889863448,0.2739084814778987,0.8840955256626168,0.5866993330591689,0.6090607826029746,0.10729869673176262,0.6655624011114719,0.8798826368637587,0.9440672858391715,0.2772186512560174,0.8223247030269625,0.23786003616201434,0.23482482735902477,0.023897370504802562,0.2667731702971038,0.42263907569971204,0.025519123478288774,0.31098121954816393,0.5852931080923512,0.01099980658464339,0.42233789074261985,0.4987296539873759,0.5885674394730634,0.10886816626248919,0.5249295274885069,0.6406864314019819,0.3209301455068545,0.996466660669097,0.9876067372018287,0.28003249410939013,0.1661598676833962,0.8941525215393364,0.6114312777591719,0.3413495741570085,0.7702323413249824,0.8091590374012378,0.7040608465491722,0.8453112181393747,0.09545986272244056,0.16910763138201057,0.5078925431309863,0.41988622380409746,0.8488461261406371,0.7508383648572723,0.9827905219052574,0.7416347244882205,0.8315048375813759,0.014908403136071113,0.16533607889512147,0.5389656903788468,0.7558793902896018,0.3287927207488617,0.623971073348554,0.6826497950749889,0.6803138596292142,0.08764492055267203,0.4375912830416836,0.7447978742045154,0.673878841729944,0.5941674529086157,0.3730817946569106,0.37816765881007175,0.25237933570147386,0.20777866802948508,0.9077723344022245,0.7294519405564825,0.761230732962565,0.8891988070244012,0.16761292872444444,0.23486740378027104,0.03689391097146555,0.9057289948200331,0.8913181056177767,0.2951654179371319,0.3684878016431935,0.6557224304256603,0.7011393900634383,0.15382355484083288,0.6292082677617965,0.08229740385737827,0.8179119736929198,0.6732057636237487,0.6964930288479623,0.20632457745321553,0.6399061047061547,0.9894417151514997,0.6050354616536279,0.20268429797905174,0.9300672718600876,0.647990224574756,0.625798106238543,0.5604684568088206,0.37450453512029636,0.7690371308543846,0.8156659419359914,0.17338852432530727,0.5083052063883768,0.5734538271624545,0.9995618558996109,0.5370354271080835,0.817451066833082,0.3108729500725299,0.710359242824343,0.8851790550718077,0.19564455977913464,0.08317395338693778,0.5808371058411572,0.882673260058457,0.5678378472876628,0.44975250107291553,0.5088202690139051,0.7205362806216047,0.12806973750922956,0.1899686698041244,0.6480585653129589,0.9679410296079957,0.82880880762769,0.3583959242062723,0.2594490637940371,0.8388359486426721,0.15232123804280107,0.9182021521707103,0.90642712189835,0.39979482563626034,0.7824169739379419,0.3185100158656442,0.4931318502184604,0.06000500166261835,0.8966626092915407,0.6920796492541434,0.5837010354605806,0.921918901480158,0.9064148700864909,0.602759456668638,0.03698196871840054,0.5697420029582988,0.7894996305624565,0.7990210156810036,0.08727393447099063,0.39744121644209385,0.44152727954414694,0.14809255841705304,0.1045248623995616,0.8915789745398953,0.9146118896838917,0.23783487506326417,0.734867573302432,0.3415461148924319,0.26033190017947494,0.21494549484661785,0.7684884486837447,0.48275430638306405,0.9834386386058233,0.5663867974950146,0.7043151098713574,0.16283908559573346,0.31518318902253495,0.27537778173731153,0.013053714606376943,0.13576432637409508,0.061999891090137704,0.8751876370965922,0.20363660236126013],\"y\":[0.0051671186625875665,0.0014874037243848282,0.18438562450012896,0.1382095884378114,0.8553446897346052,0.2553719380258045,0.9361304464734814,0.3384137486790224,0.9605213809479171,0.3771330016834371,0.33546472345110223,0.5459477233610123,0.12984813341239143,0.883751005917216,0.18491404561757108,0.8682697496346417,0.6604008062948001,0.5323980668926633,0.5266188994824064,0.19696142737533284,0.8964952597372468,0.694223895761228,0.5683155529760638,0.12292456672535224,0.0003827687516848588,0.24601386915841417,0.8642116601147164,0.9059791219351759,0.5320483874405529,0.5800828286362352,0.04460422009507137,0.47446665094733087,0.03511705928616571,0.1823212239918759,0.30482500981491956,0.10440845429355605,0.09719302441066069,0.538540349781875,0.49581634896520976,0.6589767434960416,0.7387688834423185,0.7570636874153257,0.9540782456709478,0.0139479319884116,0.6867712384352187,0.736510714650576,0.9139985629872989,0.6436342683934535,0.4940652482857698,0.26516864177818744,0.98200569472107,0.7616177917444374,0.43359953349360447,0.6854854655609888,0.5819726408652934,0.8339587577718741,0.6023336920700039,0.8263985313249911,0.9500705006479113,0.024127834286495786,0.9870479107366983,0.2974943745861691,0.5046381441696889,0.21679108982016515,0.22369737680887614,0.34550569405016995,0.9655611519877161,0.9667019251109754,0.22682527370089467,0.5577198045267293,0.32786191718299507,0.32032897932270976,0.061897214964738545,0.4853074960203396,0.35794027532213657,0.37254857965273835,0.4366111844722883,0.36296051068027446,0.20276282290156422,0.2553936877372244,0.7769353048860522,0.6782435697652642,0.17099476498161958,0.9218390866171878,0.2932290336193373,0.11074292984803613,0.204819702520866,0.5622574628992052,0.14514768029646474,0.15937547169883293,0.14483810299588662,0.9877344715738346,0.2355513073566613,0.8696370173829516,0.18632967564338154,0.6523156460251613,0.6037650687463241,0.190568103388005,0.13105233358263413,0.2339697603794021,0.3269986999573844,0.4785360362947042,0.11860157926244919,0.022798362417580598,0.05454923246296939,0.7819561930695142,0.15493611136787666,0.8428167963613531,0.01607908526944657,0.345096909705905,0.936189270170067,0.422156743741253,0.8071898222399161,0.706161627823573,0.3872893350218156,0.6843334198046196,0.5210271973063695,0.38397243777058987,0.18063737842840477,0.06060389535795041,0.41019521866416453,0.6942761678478745,0.9561115941409702,0.26275647115595757,0.16798478190627708,0.8367263098665012,0.44721611619917534,0.9249813550242181,0.30401204980380314,0.7177813587365868,0.437836030474661,0.9543430433124112,0.29623454012419603,0.6014604139483003,0.5315941656426464,0.07217321580247615,0.8501144870478663,0.17595265675596194,0.6054749235976907,0.8960902441092429,0.09707711892394943,0.6999176974718399,0.13123830573569573,0.3448691380826099,0.4017201217650739,0.23862015863856167,0.039966870795909215,0.8838493122977317,0.23210699058255901,0.8634971519220701,0.910092480458328,0.9976992140281297,0.24553067450322386,0.5749267046120843,0.3707433450209898,0.22804726491076477,0.9217144343317742,0.9440718246398699,0.7454629594590647,0.7984991537194668,0.07085936058059694,0.9373323314813637,0.40238831755440674,0.8163152425674265,0.41463237378612006,0.7748488500206661,0.20116585214004812,0.1756976846245779,0.7297598844804718,0.6322827527887095,0.2694043454959012,0.6827420689406241,0.30427683897147395,0.8700344221458102,0.6898023085556514,0.2635495838927161,0.9163564300941138,0.6011310320632369,0.2757651302159565,0.5613908820489945,0.7514314956392545,0.07217800426697596,0.2585955810256081,0.47347308328388615,0.5982269377411574,0.8783425004090404,0.8481314241917954,0.748611864431629,0.4587180974488978,0.24099914627068175,0.18514665132877317,0.9742385620343825,0.30643478054657847,0.2401593830237665,0.6303904991787044,0.42516713745264934,0.761955831102177,0.50973807953341,0.00921637616402804,0.8669989809207796,0.10873699476105214,0.48102038944996994,0.23853798451047092,0.8161810922324644,0.38473734859570463,0.32702986509742504,0.6325168250554579,0.7023825605245396,0.8046668030712019,0.4760418686143436,0.39373612112921175,0.8725379183020975,0.6705561145063823,0.41598497962521286,0.9515863908749839,0.597926448776197,0.06883034230765472,0.03739159733027053,0.9489215736092398,0.7772985974487849,0.28639322978519843,0.18811270707755423,0.4971840917805761,0.43502909226106157,0.7953375744557107,0.5574449452496433,0.9178537733080883,0.9641445592561475,0.7451971536586829,0.08638943891570894,0.40142319274765237,0.14251622345114112,0.3564856135377392,0.8093939046734027,0.05841003436638281,0.10350306985651636,0.7758324641743513,0.5837108008758726,0.11243172655650491,0.9076028208391752,0.035240868302629735,0.6406361604333567,0.20096287383360956,0.27840332714649707,0.8215429077379371,0.035114168802025,0.042356474656929155,0.09346016507978994,0.14031800200773759,0.49524812960292,0.8017108156846805,0.6410722699191647,0.07961869908881003,0.21635726761003327,0.27176715127755424,0.7997565591473609,0.646848496713535,0.2217281461256908,0.4738919472796991,0.41135153305006067,0.49875113624502565,0.8861756872587377,0.9742847802782273,0.21328589407388976,0.616693063566901,0.16448215132386113,0.08602318727492597,0.5773723604074743,0.7015858200266414,0.9131787165948042,0.6335994042643489,0.8988261536776108,0.41084476761096933,0.08008421615664774,0.2099404052207895,0.02982232120762751,0.14450835814473273,0.2799559291962713,0.9334145791130334,0.5005438264044634,0.85661595855483,0.8559656584613012,0.08647370334331816,0.16927340595000762,0.630435625997731,0.06757871774673052,0.9523693470377498,0.5242723894836445,0.6398104205918518,0.6752066554870929,0.18105588181648058,0.9045078026017468,0.16126736230498873,0.28282956979370744,0.43278274341547474,0.0927949276294805,0.3099577788521015,0.43129314725328327,0.4180835339828287,0.1064047440381134,0.5466033257697831,0.47166271580085783,0.2001570661122165,0.8853328560127267,0.8161051054152434,0.9834790727555371,0.010557664834826785,0.6570934225814613,0.7895310801238348,0.10471294502648754,0.704142962264627,0.5020501048543528,0.2664858746970742,0.8192769681855897,0.05486782515404187,0.9965909224007644,0.10462136136664235,0.13828848490613344,0.9199653177756053,0.8023820552715047,0.9020427180028915,0.3799333692907453,0.8751208843384248,0.02283120868924149,0.06528490405443721,0.783971331755705,0.8004739439284674,0.316807199041388,0.6695145063261457,0.5458394548634354,0.5713717927141426,0.09559062866898449,0.9169642657365777,0.8028724396742173,0.38634779457100654,0.7046721558041797,0.20266591950605395,0.8095805687422084,0.05043387058599369,0.804462701783172,0.3342267786716092,0.47705530425405696,0.821946925223157,0.31248374545713964,0.4709422488757733,0.4886529376278541,0.0012078772236431279,0.23563058365769318,0.5636521232116052,0.19139825709376357,0.013817780673103908,0.7366457514486372,0.2518936479464924,0.44815381141631006,0.29651567390531575,0.8789588651529043,0.47943994569201376,0.07826366875920043,0.20277475425445224,0.2214419280679144,0.6233637479320706,0.8652813129125357,0.8880642985277439,0.19233390295525998,0.9287777040375813,0.02287069524020402,0.35244894941757665,0.5252282421966917,0.2851524069153176,0.9098261584812253,0.737789072097878,0.2839944856758676,0.39667825016499325,0.06451657962433421,0.8284281589102311,0.10200335779054015,0.1378021854115038,0.6615673669858324,0.5798473263625671,0.40591117718745395,0.9601968823054746,0.19642962499069616,0.42691835097306097,0.4047770987251512,0.2694826585696465,0.9407287507038167,0.15351670437315268,0.1010338160634906,0.6924348500121331,0.3252467172231869,0.38455038510597417,0.13492429642494685,0.46003415413887205,0.6962840059817631,0.6304650750924897,0.4277461466541226,0.4801851445592138,0.01927377453355905,0.5887168429164253,0.9938496599782799,0.5911728216102798,0.7048547370146654,0.23946110942221444,0.2176549967622542,0.8785674630568245,0.02240479327616185,0.3583555372936278,0.38856608088998523,0.1880180752015329,0.9751919418176324,0.7648357190447469,0.5714462666302585,0.8660191422418295,0.6234038462282371,0.8348766088111256,0.3632726512997445,0.3897383444866025,0.8551862056647418,0.12168347681018388,0.14248314316530586,0.665616494955324,0.9292145522345526,0.8124957453004482,0.1635820123215015,0.07102297904743637,0.7363831823142629,0.12067161591223474,0.46245312525081195,0.2041366685881022,0.5184576539678825,0.4577039273825142,0.3617397168363644,0.08725527082944229,0.05083889319552548,0.7217549864174783,0.1029826686432912,0.5252080138321654,0.6431437295500823,0.5252669899001131,0.4901600395687574,0.20731284252865823,0.3251523122121185,0.1791580166938982,0.8050307639851573,0.5460364205170667,0.3984603703285917,0.9982796361893531,0.39655099808213257,0.2353284268991792,0.8900921100857103,0.4040228206664913,0.9406217796252359,0.42873358250558347,0.9714066197453668,0.0597824870586493,0.4220679989856042,0.3562875803563562,0.07291589210329619,0.5076583810590097,0.24754569973753282,0.9227952768665133,0.16253805095918605,0.029093733264954347,0.7625934936037466,0.7647675179502285,0.8459335316483321,0.475141212472558,0.17277504223513362,0.5019361976605029,0.016444583409473967,0.5787530929987642,0.1276097288366349,0.7788066749642021,0.9778478907442778,0.04681529069633783,0.642834605383125,0.8138033353986355,0.8553387478099956,0.5517988402062854,0.8020094434255457,0.39734231389090446,0.4512667353994766,0.7105561288180172,0.2170796045970299,0.0962794780389562,0.9623431068520268,0.16861452032516178,0.8713625860654614,0.49830165754310607,0.8910732964378028,0.25931838864806744,0.8092923010142463,0.8090527541229886,0.6229825944178256,0.15151126852925767,0.24525077028740128,0.7474267664450308,0.16993947812437227,0.7262442037562473,0.4039792105869735]}},\"id\":\"f8c26d6c-b6a0-449f-8f34-51651453c19e\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"data_source\":{\"id\":\"4b64acfb-e8fd-4d1f-8f1b-bf8c9e3734f9\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"828245e1-78fc-491a-ad8c-5de71fb48337\",\"type\":\"Line\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"c642bee1-b2e7-46f2-900e-e865e22abd20\",\"type\":\"Line\"},\"selection_glyph\":null,\"view\":{\"id\":\"bce2c547-052c-4b61-b3ba-46ee0fd8a06a\",\"type\":\"CDSView\"}},\"id\":\"958b31da-9d7f-43c1-953d-8f112c1f89d6\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"f8c26d6c-b6a0-449f-8f34-51651453c19e\",\"type\":\"ColumnDataSource\"}},\"id\":\"664e9a0e-92aa-43af-8f42-603c3cd60c1c\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"c24e2bb1-91f5-413a-b597-193c78e350f4\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.5},\"fill_color\":{\"value\":\"lightgrey\"},\"level\":\"overlay\",\"line_alpha\":{\"value\":1.0},\"line_color\":{\"value\":\"black\"},\"line_dash\":[4,4],\"line_width\":{\"value\":2},\"plot\":null,\"xs_units\":\"screen\",\"ys_units\":\"screen\"},\"id\":\"04e8eb75-f8c8-4467-8a4c-d4d8ecf53d9d\",\"type\":\"PolyAnnotation\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"xm\",\"ym\"],\"data\":{\"xm\":[0,1],\"ym\":[0.5,0.5]}},\"id\":\"4b64acfb-e8fd-4d1f-8f1b-bf8c9e3734f9\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"c24e2bb1-91f5-413a-b597-193c78e350f4\",\"type\":\"BasicTicker\"}},\"id\":\"7f9f950f-325b-4482-b9c8-74aec5450cc4\",\"type\":\"Grid\"},{\"attributes\":{\"formatter\":{\"id\":\"a358809a-1a3f-4506-9faa-182c37113e51\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"51c0ad27-c0ea-4bba-817c-233a03cf6e5e\",\"type\":\"BasicTicker\"}},\"id\":\"d87891bd-5139-4af7-80f0-b45222ed08b6\",\"type\":\"LinearAxis\"},{\"attributes\":{\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"line_width\":{\"value\":5},\"x\":{\"field\":\"xm\"},\"y\":{\"field\":\"ym\"}},\"id\":\"c642bee1-b2e7-46f2-900e-e865e22abd20\",\"type\":\"Line\"},{\"attributes\":{},\"id\":\"4b5b4894-0008-4a2d-b236-9290dbf05ecd\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"below\":[{\"id\":\"d87891bd-5139-4af7-80f0-b45222ed08b6\",\"type\":\"LinearAxis\"}],\"left\":[{\"id\":\"098ef1e5-7460-41ad-afba-e402eb45c877\",\"type\":\"LinearAxis\"}],\"plot_height\":400,\"plot_width\":400,\"renderers\":[{\"id\":\"d87891bd-5139-4af7-80f0-b45222ed08b6\",\"type\":\"LinearAxis\"},{\"id\":\"3c733c27-0be1-4820-8c16-08911534d0f9\",\"type\":\"Grid\"},{\"id\":\"098ef1e5-7460-41ad-afba-e402eb45c877\",\"type\":\"LinearAxis\"},{\"id\":\"7f9f950f-325b-4482-b9c8-74aec5450cc4\",\"type\":\"Grid\"},{\"id\":\"04e8eb75-f8c8-4467-8a4c-d4d8ecf53d9d\",\"type\":\"PolyAnnotation\"},{\"id\":\"bdb9dba1-0262-42e5-929e-feaf13e5df2c\",\"type\":\"GlyphRenderer\"},{\"id\":\"958b31da-9d7f-43c1-953d-8f112c1f89d6\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"244314f4-cb14-45b7-95fd-b31b515e8251\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"e98d1b3a-b36d-440c-8104-090f72e93bd2\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"22ee51a5-8b12-4e80-a68d-9d7e6fbc5229\",\"type\":\"DataRange1d\"},\"x_scale\":{\"id\":\"5afb3e8b-a079-42a9-8885-96799f5884b4\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"1866a425-d79c-4b4f-9b1b-789bdd33ce8a\",\"type\":\"DataRange1d\"},\"y_scale\":{\"id\":\"d58121ea-1d22-45bf-991f-341fee564f8d\",\"type\":\"LinearScale\"}},\"id\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\",\"subtype\":\"Figure\",\"type\":\"Plot\"}],\"root_ids\":[\"676317d0-526a-4076-99cb-3f55d6ee4c13\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.10\"}};\n",
       "    var render_items = [{\"docid\":\"e9031398-3da1-4fa3-9cfe-48a29194674d\",\"elementid\":\"3e2a996c-45cb-4d93-bc5d-0a1ee0ac2129\",\"modelid\":\"676317d0-526a-4076-99cb-3f55d6ee4c13\"}];\n",
       "\n",
       "    root.Bokeh.embed.embed_items(docs_json, render_items);\n",
       "  }\n",
       "\n",
       "  if (root.Bokeh !== undefined) {\n",
       "    embed_document(root);\n",
       "  } else {\n",
       "    var attempts = 0;\n",
       "    var timer = setInterval(function(root) {\n",
       "      if (root.Bokeh !== undefined) {\n",
       "        embed_document(root);\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "      attempts++;\n",
       "      if (attempts > 100) {\n",
       "        console.log(\"Bokeh: ERROR: Unable to embed document because BokehJS library is missing\")\n",
       "        clearInterval(timer);\n",
       "      }\n",
       "    }, 10, root)\n",
       "  }\n",
       "})(window);"
      ],
      "application/vnd.bokehjs_exec.v0+json": ""
     },
     "metadata": {
      "application/vnd.bokehjs_exec.v0+json": {
       "id": "676317d0-526a-4076-99cb-3f55d6ee4c13"
      }
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "from random import random\n",
    "\n",
    "x = [random() for x in range(500)]\n",
    "y = [random() for y in range(500)]\n",
    "color = [\"navy\"] * len(x)\n",
    "\n",
    "s = ColumnDataSource(data=dict(x=x, y=y, color=color))\n",
    "p = figure(plot_width=400, plot_height=400, tools=\"lasso_select\", title=\"Select Here\")\n",
    "p.circle('x', 'y', color='color', size=8, source=s, alpha=0.4)\n",
    "\n",
    "s2 = ColumnDataSource(data=dict(xm=[0,1],ym=[0.5, 0.5]))\n",
    "p.line(x='xm', y='ym', color=\"orange\", line_width=5, alpha=0.6, source=s2)\n",
    "\n",
    "s.callback = CustomJS(args=dict(s2=s2), code=\"\"\"\n",
    "    var inds = cb_obj.get('selected')['1d'].indices;\n",
    "    var d = cb_obj.get('data');\n",
    "    var ym = 0\n",
    "    \n",
    "    if (inds.length == 0) { return; }\n",
    "    \n",
    "    for (i = 0; i < d['color'].length; i++) {\n",
    "        d['color'][i] = \"navy\"\n",
    "    }\n",
    "    for (i = 0; i < inds.length; i++) {\n",
    "        d['color'][inds[i]] = \"firebrick\"\n",
    "        ym += d['y'][inds[i]]\n",
    "    }\n",
    "    \n",
    "    ym /= inds.length\n",
    "    s2.get('data')['ym'] = [ym, ym]\n",
    "    \n",
    "    cb_obj.trigger('change');\n",
    "    s2.trigger('change');\n",
    "\"\"\")\n",
    "\n",
    "show(p)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# 更多\n",
    "更多交互，参考用户指南 - http://bokeh.pydata.org/en/latest/docs/user_guide/interaction.html"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "widgets": {
   "state": {
    "335ae2c8ff80469e9adac668c2924989": {
     "views": [
      {
       "cell_index": 19
      }
     ]
    }
   },
   "version": "1.2.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
